home *** CD-ROM | disk | FTP | other *** search
Text File | 2003-07-17 | 100.2 KB | 4,056 lines |
- // Copyright (C) 1997-2002 Alias|Wavefront,
- // a division of Silicon Graphics Limited.
- //
- // The information in this file is provided for the exclusive use of the
- // licensees of Alias|Wavefront. Such users have the right to use, modify,
- // and incorporate this code into other products for purposes authorized
- // by the Alias|Wavefront license agreement, without fee.
- //
- // ALIAS|WAVEFRONT DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
- // INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
- // EVENT SHALL ALIAS|WAVEFRONT BE LIABLE FOR ANY SPECIAL, INDIRECT OR
- // CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
- // DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
- // TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
- // PERFORMANCE OF THIS SOFTWARE.
- //
- //
- // Alias|Wavefront Script File
- // MODIFY THIS AT YOUR OWN RISK
- //
- // Creation Date: September 16, 1998
- //
- // Description:
- //
- // Creates a panel that contains the rendering window.
- // This file also contains a bunch of helper procedures related to the
- // rendering window.
- //
-
-
- // This file is organized in the following order.
- //
- // - Utility procedures used by other procedures in the file
- // - Procedures called when menu commands are chosen
- // - Procedures which generate the menus and refresh the menus each time the
- // particular menu is opened
- // - Procedures which call the menu generation procedures and create other
- // user interface elements within the render view window or panel
- // - Procedures which are accessed from outside the renderview
- // - Procedures which support scripted panel capability
- //
- // Conventions:
- //
- // - $editor is the name of the scripted panel object which is the render view
- // panel
-
- global int $gIprTuningPaused = false;
-
- //----------------------------------------------------------------------------//
- // Utility procedures
- //----------------------------------------------------------------------------//
-
-
- //
- // Description:
- // Sets all the option var specific to the render view.
- // - renderViewTestResolution: 0 => panel resolution.
- // 1 => render globals.
- // 2 => 50% render globals.
- // 3 => 25% render globals.
- // 4 => 10% render globals.
- // - renderViewAutoResize: boolean
- // - renderViewAutoRenderRegion: boolean.
- //
- global int $renderViewShadowsMode = 0;
- global int $renderViewGlowPassMode = 0;
- global proc setRenderOptionVars()
- {
- if( !`optionVar -exists renderViewTestResolution` )
- {
- // Default value: 1 => render globals
- //
- optionVar -intValue renderViewTestResolution 1;
- }
- if( !`optionVar -exists renderViewAutoResize` )
- {
- optionVar -intValue renderViewAutoResize 1;
- }
- if( !`optionVar -exists renderViewAutoRenderRegion` )
- {
- optionVar -intValue renderViewAutoRenderRegion 0;
- }
-
- // For the long run, we should add a flag to the
- // renderWindowEditor which will allow us to associate
- // a file name with an image.
- // Also, we should make sure that each image in the
- // renderview buffer can have a name associated with it.
- // (code reivew comments from Josh, Sept. 15, Corina Wang)
- //
- if( !`optionVar -exists renderedImageName` )
- {
- optionVar -stringValue renderedImageName "test";
- }
-
- // IPR option variables which don't depend on the iprEngine
- //
-
- if( !`optionVar -exists iprRenderShading` )
- {
- optionVar -intValue iprRenderShading true;
- }
- if( !`optionVar -exists iprRenderShadowMaps` )
- {
- optionVar -intValue iprRenderShadowMaps true;
- }
- if( !`optionVar -exists iprRenderMotionBlur` )
- {
- optionVar -intValue iprRenderMotionBlur true;
- }
- }
-
- //
- // Description:
- // Returns the render window editor, creates it if needed.
- //
- proc string getRenderWindowPanel()
- {
- string $renderPanel;
- string $renderPanels[] = `getPanel -scriptType "renderWindowPanel"`;
-
- if( size($renderPanels) == 0 )
- {
- $renderPanel = `scriptedPanel -type "renderWindowPanel" -unParent`;
- scriptedPanel -e -label `interToUI $renderPanel` $renderPanel;
- }
- else
- {
- $renderPanel = $renderPanels[0];
- }
-
- return $renderPanel;
- }
-
- proc int isIprFileLoaded()
- {
- // Returns 1 if the active image has a ipr image behind it.
- //
- if (`iprEngine -query -exists defaultIprEngine`) {
-
- string $iprImageName[] = `iprEngine -q -iprImage defaultIprEngine`;
- if (size($iprImageName) > 0)
- if ($iprImageName[0] != "")
- return true;
- }
- return false;
- }
-
- proc initializeIprOptionVars(string $iprEngine)
- //
- // Description:
- // Sets all the option vars specific to IPR.
- //
- {
- //
- // Set the options variables.
- //
- if( !`optionVar -exists updateShadingAndLighting` )
- {
- optionVar -intValue updateShadingAndLighting 1;
- }
- if( !`optionVar -exists updateLightGlow` )
- {
- optionVar -intValue updateLightGlow 1;
- }
- if( !`optionVar -exists updateShaderGlow` )
- {
- optionVar -intValue updateShaderGlow 1;
- }
- if( !`optionVar -exists updateMotionBlur` )
- {
- optionVar -intValue updateMotionBlur 1;
- }
-
- // Set the state on the engine.
- //
- iprEngine -edit
- -updateShading `optionVar -query updateShadingAndLighting`
- $iprEngine;
-
- iprEngine -edit
- -updateLightGlow `optionVar -query updateLightGlow`
- $iprEngine;
-
- iprEngine -edit
- -updateShaderGlow `optionVar -query updateShaderGlow`
- $iprEngine;
-
- iprEngine -edit
- -updateMotionBlur `optionVar -query updateMotionBlur`
- $iprEngine;
- }
-
- global proc updateIPRMemoryEstimate()
- {
- string $displayedMemory = "IPR: ";
-
- if (isIprFileLoaded()) {
- string $memEstimate[] =
- `iprEngine -q -estimatedMemory defaultIprEngine`;
-
- if ($memEstimate[0] == "0MB") {
- // Prompt the user to select a region to begin tuning
- //
- renderWindowEditor
- -edit
- -caption "Select a region to begin tuning"
- `getRenderWindowPanel`;
- }
-
- $displayedMemory = ($displayedMemory + $memEstimate[0]);
- } else {
- $displayedMemory = ($displayedMemory + "0MB");
- }
-
- text -edit -label $displayedMemory iprMemEstText;
- }
-
- proc beginIprSession(string $editor)
- {
- if (!`iprEngine -query -exists defaultIprEngine`)
- {
- // Create an IPR engine
- //
- iprEngine defaultIprEngine;
-
- // Set the state on this engine using optionVars.
- initializeIprOptionVars "defaultIprEngine";
-
- // Set the flag indicating whether IPR tuning is paused
- //
- global int $gIprTuningPaused;
- $gIprTuningPaused = false;
- renderWindowRefreshMenu("ipr", $editor);
- }
-
- scriptJob
- -parent $editor
- -replacePrevious
- -event SceneOpened ("renderWindowMenuCommand closeIprFile " + $editor);
- }
-
- proc endIprSession(string $editor)
- {
- // Delete the IPR engine
- //
- if (isIprFileLoaded()) {
- iprEngine
- -edit
- -releaseIprImage
- defaultIprEngine;
-
- deleteUI defaultIprEngine;
- }
-
- // Delete the IPR default light, if there is one. If there is indeed one,
- // it will be the directional light with the dynamic attribute
- // isIPRDefaultLight.
- //
-
- string $directionalLights[] = `ls -type directionalLight`;
-
- string $light;
-
- for ($light in $directionalLights)
- {
- if (`objExists ($light + ".isIPRDefaultLight")`)
- {
- // Delete the transform (i.e., parents[0]), not just the light,
- // and make sure it doesn't go on undo queue.
- //
- string $parents[] = `listRelatives -parent $light`;
- int $undoOn = `undoInfo -query -swf`;
- if ($undoOn)
- undoInfo -swf off;
-
- delete $parents[0];
- if ($undoOn)
- undoInfo -swf on;
-
- break;
- }
- }
-
-
- // Update the memory estimate.
- //
- updateIPRMemoryEstimate();
-
- // Set the flag indicating whether IPR tuning is paused
- //
- global int $gIprTuningPaused;
- $gIprTuningPaused = false;
- renderWindowRefreshMenu("ipr", $editor);
- }
-
- proc unloadSamples(string $editor)
- {
- // Update the UI to indicate that no samples are loaded
- //
- }
-
- proc int isImageLoaded(string $editor)
- {
- return (`renderWindowEditor -query -nbImages $editor` != -1);
- }
-
- proc string changeWorkspaceDir(string $newDirType)
- {
- string $rootDir = `workspace -query -rootDirectory`;
- string $currentDir = `workspace -query -directory`;
- string $renderDirs[] = `workspace -query -renderType`;
- string $newDir = $currentDir;
-
- int $i;
- for ($i = 0; $i < size($renderDirs); $i += 2)
- {
- if ($renderDirs[$i] == $newDirType)
- {
- $newDir = $renderDirs[$i+1];
- }
- }
-
- workspace -directory $rootDir;
- workspace -directory $newDir;
- return $currentDir;
- }
-
- proc int[] getGlobalsResolution()
- {
- //
- // Render globals item.
- //
- string $globals[] = `ls -renderGlobals`;
- int $res[2] = { 320, 240 };
-
- if( size($globals[0]) > 0 )
- {
- string $connect[] = `listConnections ($globals[0] + ".resolution")`;
-
- if( size($connect[0]) > 0 )
- {
- $res[0] = `getAttr ($connect[0] + ".width" )`;
- $res[1] = `getAttr ($connect[0] + ".height" )`;
- }
- }
-
- return $res;
- }
-
- // Description: Get the test resolution for the current renderer.
- //
- proc int[] getTestResolution( string $panel )
- {
- int $res[2] = { 320, 240 };
-
- if( `optionVar -exists renderViewTestResolution` )
- {
- $testRes = `optionVar -query renderViewTestResolution`;
-
- if( $testRes == 0 )
- {
- if( size($panel) )
- {
- string $modelViewControl = `modelEditor -q -control $panel`;
-
- if( size($modelViewControl) && `control -ex $modelViewControl` )
- {
- $res[0] = `control -q -w $modelViewControl`;
- $res[1] = `control -q -h $modelViewControl`;
- }
- }
- }
- else
- {
- string $hasCommonGlobalValueProc =
- `renderer -query -hasCommonGlobalValueProcedure (currentRenderer())`;
- string $getCommonGlobalValueProc =
- `renderer -query -getCommonGlobalValueProcedure (currentRenderer())`;
-
- if( $hasCommonGlobalValueProc != "" &&
- $getCommonGlobalValueProc != "" &&
- eval($hasCommonGlobalValueProc+" width") &&
- eval($hasCommonGlobalValueProc+" height"))
- {
- // Use getCommonGlobalValueProc to get the width and height.
- //
- $res[0] = eval($getCommonGlobalValueProc+" width");
- $res[1] = eval($getCommonGlobalValueProc+" height");
-
- if( $testRes == 2 )
- {
- $res[0] /= 2;
- $res[1] /= 2;
- }
- else if( $testRes == 3 )
- {
- $res[0] /= 4;
- $res[1] /= 4;
- }
- else if( $testRes == 4 )
- {
- $res[0] /= 10;
- $res[1] /= 10;
- }
- }
- }
- }
-
- return $res;
- }
-
- proc string getRenderWindowPanelFormLayout()
- {
- string $panel[] = `getPanel -scriptType "renderWindowPanel"`;
- return `renderWindowEditor -query -parent $panel[0]`;
- }
-
- //
- // Description:
- // Returns the current camera stored by the render window editor.
- // returns the current camera view if nothing stored in the render view or
- // the first camera.
- //
- proc string getCurrentCamera()
- {
- string $renderPanel = `getRenderWindowPanel`;
- string $camera = `renderWindowEditor -q -currentCamera $renderPanel`;
-
- if( !size($camera) )
- {
- //
- // So gets the current camera.
- //
- string $currentPanel = `getPanel -wf`;
-
- if( `modelPanel -exists $currentPanel` )
- {
- $camera = `modelPanel -q -cam $currentPanel`;
- }
- else
- {
- // Since we have to make a guess at what camera to use, we'll
- // first guess that it's something typical (namely: persp).
- // If that's not a good guess, we'll just guess that it's the
- // first camera in the scene.
- //
- int $useFirstCamera = true;
-
- string $defCameras[] = `ls persp|perspShape`;
- if (size($defCameras) > 0) {
- string $defCamera = $defCameras[0];
- if (`nodeType $defCamera` == "camera") {
- $camera = $defCamera;
- $useFirstCamera = false;
- }
- }
-
- if ($useFirstCamera) {
- string $cameras[] = `ls -cameras`;
- $camera = $cameras[0];
- }
- }
- }
-
- return $camera;
- }
-
- proc string getCameraPanel( string $camera )
- {
- string $cameraPanel;
-
- for( $modelPanel in `getPanel -type "modelPanel"` )
- {
- $cameraPanel = `modelPanel -q -cam $modelPanel`;
-
- if( $cameraPanel == $camera )
- {
- return $modelPanel;
- }
- }
-
- string $null = "";
- return $null;
- }
-
- //
- // Description:
- // Raise the render view window if exists, then return 1.
- // Return 0 otherwise.
- //
- proc int raiseRenderViewWindow()
- {
- //
- // Look for the renderViewWindow and pop it up if it exists.
- //
- for( $i in `lsUI -windows` )
- {
- if( $i == "renderViewWindow" )
- {
- showWindow $i;
- return 1;
- }
- }
-
- return 0;
- }
-
- proc string showRenderView()
- {
- // Ensures that the Render View is displayed.
- // If the Render View is currently torn-off in a window, the window is
- // brought forward. If the Render View does not exist in a torn-off window
- // nor in a panel, it is created in a torn-off window.
- //
- // Returns the name of the render view.
- //
-
- string $editor;
-
- $editor = `getRenderWindowPanel`;
-
- if( `raiseRenderViewWindow` == 1 )
- {
- // The Render View exists and is in a torn-off window. It has been
- // brought to the front.
- //
- return $editor;
- }
-
- // If we get to here, the Render View is not in a torn-off window
- //
- for( $i in `getPanel -vis` )
- {
- if( $i == $editor )
- {
- // The Render View exists and is in a panel.
- //
- return $editor;
- }
- }
-
- // If we get to here, the Render View is not currently in a panel nor is
- // it in a torn-off window.
- //
- scriptedPanel
- -edit
- -tearOff
- $editor;
-
- return $editor;
- }
-
- proc int isToolbarDisplayed ()
- {
- if( `optionVar -exists renderViewDisplayToolbar` )
- {
- return `optionVar -query renderViewDisplayToolbar`;
- }
- else
- {
- optionVar -intValue renderViewDisplayToolbar 1;
- return 1;
- }
- }
-
- proc displayToolbar (int $display)
- {
- optionVar -intValue renderViewDisplayToolbar $display;
- }
-
- proc toggleDisplayToolbar()
- {
- if (isToolbarDisplayed())
- {
- displayToolbar(false);
- }
- else
- {
- displayToolbar(true);
- }
- }
-
- //----------------------------------------------------------------------------//
- // Procedures which are called when menu items are chosen
- //----------------------------------------------------------------------------//
-
- proc loadImage(string $editor)
- {
- string $callbackCmd;
- $callbackCmd = ("renderWindowLoadImageCallback \"" + $editor + "\"");
-
- string $prevDir = changeWorkspaceDir("images");
-
- // 0 for a read browser
- //
- fileBrowser $callbackCmd "Load Image" "image" 0;
-
- changeWorkspaceDir($prevDir);
- }
-
- global proc int renderWindowLoadImageCallback(
- string $editor,
- string $fileName,
- string $fileType)
- {
- // Called by the file browser with the name and type of the file the user
- // has chosen
- //
- if ($fileName != "")
- {
- renderWindowEditor
- -edit
- -loadImage $fileName
- $editor;
- }
-
- // Return 1 to close the file browser
- //
- return 1;
- }
-
- proc saveImage(string $editor)
- {
- string $callbackCmd;
- $callbackCmd = ("renderWindowSaveImageCallback \"" + $editor + "\"");
-
- string $prevDir = changeWorkspaceDir("images");
-
- // 1 for a write browser
- //
- fileBrowser $callbackCmd "Save Image" "image" 1;
-
- changeWorkspaceDir($prevDir);
- }
-
- global proc int renderWindowSaveImageCallback(
- string $editor,
- string $fileName,
- string $fileType)
- {
- // Called by the file browser with the name and type of the file the user
- // has chosen
- //
- if ($fileName != "")
- {
- renderWindowEditor
- -edit
- -writeImage $fileName
- $editor;
- }
-
- // Return 1 to close the file browser
- //
- return 1;
- }
-
- proc loadIprFile(string $editor)
- {
- string $callbackCmd;
- $callbackCmd = ("renderWindowLoadIprFileCallback \"" + $editor + "\"");
-
- string $prevDir = changeWorkspaceDir("iprImages");
-
- // 0 for a read browser
- //
- fileBrowser $callbackCmd "Load IPR File" "iff" 0;
-
- changeWorkspaceDir($prevDir);
- }
-
- proc closeIprFile(string $editor)
- {
- unloadSamples($editor);
- endIprSession($editor);
- }
-
- global proc int renderWindowLoadIprFileCallback(
- string $editor,
- string $fileName,
- string $fileType)
- {
- // Called by the file browser with the name and type of the file the user
- // has chosen
- //
- if ($fileName != "")
- {
- // Now that we have an IPR file, we can enable IPR
- //
- beginIprSession($editor);
-
- // Register the file with the IPR engine
- //
- iprEngine
- -edit
- -iprImage $fileName
- defaultIprEngine;
-
- // Prompt the user to select a region to begin tuning
- //
- renderWindowEditor
- -edit
- -caption "Select a region to begin tuning"
- $editor;
-
- // Update UI which needs to be changed
- //
- renderWindowRefreshLayout($editor);
- renderWindowRefreshMenu("file", $editor);
- renderWindowRefreshMenu("ipr", $editor);
- }
-
- // Return 1 to close the file browser
- //
- return 1;
- }
-
- proc saveIprFile(string $editor)
- {
- string $callbackCmd;
- $callbackCmd = ("renderWindowSaveIprFileCallback \"" + $editor + "\"");
-
- string $prevDir = changeWorkspaceDir("iprImages");
- string $workspace = `workspace -fn`;
-
- // 1 for a write browser
- //
- fileBrowser $callbackCmd "Save IPR File" "iff" 2;
-
- changeWorkspaceDir($prevDir);
- }
-
- global proc int renderWindowSaveIprFileCallback(
- string $editor,
- string $inFileName,
- string $fileType)
- {
- // Called by the file browser with the name and type of the file the user
- // has chosen
- //
- if ($inFileName != "")
- {
- // Expand the filename to its full name.
- string $fileName = `workspace -expandName $inFileName`;
-
- if (isIprFileLoaded()) {
- // copy the current ipr file to the specified fileName
- iprEngine -edit -copy $inFileName defaultIprEngine;
- }
- }
-
- // Return 1 to close the file browser
- //
- return 1;
- }
-
- global proc renderWindowRenderCamera(
- string $renderMode,
- string $editor,
- string $camera)
- {
- global int $renderViewShadowsMode;
- global int $renderViewGlowPassMode;
-
- // Ensure we have someplace to render to...
- //
- if ($editor == "")
- {
- $editor = `showRenderView`;
- }
-
- // Cancel the Hypershade snapshot if it is still going
- //
- if (`renderWindowEditor -query -snapshotMode $editor`) {
- renderWindowMenuCommand("grabSwatch", $editor);
- }
-
- if (isIprFileLoaded()) {
- // The user has asked to for another render and they already
- // have an IPR file loaded, ask the user if they are sure they
- // want to do this.
- //
- // We cannot do another IPR render if we are still tuning.
-
- renderWindowMenuCommand "closeIprFile" $editor;
- }
-
- // Valid arguments for renderMode are:
- // "redoPreviousRender", "renderRegion", "render", "snapshot",
- // "redoPreviousIprRender", or "iprRender".
-
- // Determine the camera to render from.
- //
- // If the camera to render from has not been specified, we
- // render from the current camera.
- //
- if ($camera == "")
- {
- $camera = `getCurrentCamera`;
- }
-
- string $cameraPanel = `getCameraPanel( $camera )`;
- int $resolution[] = `getTestResolution( $cameraPanel )`;
- string $globals[] = `ls -renderGlobals`;
-
- // Save the current render region setting of the render globals
- //
- int $prevUseRenderRegion =
- `getAttr ($globals[0] + ".useRenderRegion")`;
-
- // Determine the resolution to render at.
- //
- if (($renderMode == "renderRegion"))
- {
- setAttr ($globals[0] + ".useRenderRegion") true;
-
- //
- // Show the region.
- //
- renderWindowEditor
- -edit
- -showRegion $resolution[0] $resolution[1]
- $editor;
- }
- else
- {
- setAttr ($globals[0] + ".useRenderRegion") false;
- }
-
- // Perform the render
- //
- string $result;
-
- if ($renderMode == "snapshot")
- {
- renderWindowTakeSnapshot( $resolution[0], $resolution[1], $camera );
- }
- else if (($renderMode == "iprRender")
- || ($renderMode == "redoPreviousIprRender"))
- {
- //
- // Make sure at least one of the IPR Render options is enabled,
- // or else doing an IPR render would be useless
- //
- int $doShading = `optionVar -query iprRenderShading`;
- int $doBlur = `optionVar -query iprRenderMotionBlur`;
-
- if (!$doShading && !$doBlur) {
- warning("IPR Render requires at least one of the following options enabled:");
- print(" Render Shading, Lighting and Glow\n");
- print(" Render 2D Motion Blur\n");
- warning(
- "Turn on at least one of these options in IPR Options in Render Global Settings.");
- return;
- }
-
- // Save the current render global IPR settings
- //
- int $prevCreateIprFile =
- `getAttr ($globals[0] + ".createIprFile")`;
- int $prevIprRenderShading =
- `getAttr ($globals[0] + ".iprRenderShading")`;
- int $prevIprRenderShadowMaps =
- `getAttr ($globals[0] + ".iprRenderShadowMaps")`;
- int $prevIprRenderMotionBlur =
- `getAttr ($globals[0] + ".iprRenderMotionBlur")`;
-
- setAttr ($globals[0]+".createIprFile")
- true;
- setAttr ($globals[0]+".iprRenderShading")
- `optionVar -query iprRenderShading`;
- setAttr ($globals[0]+".iprRenderShadowMaps")
- `optionVar -query iprRenderShadowMaps`;
- setAttr ($globals[0]+".iprRenderMotionBlur")
- `optionVar -query iprRenderMotionBlur`;
-
- // Perform the IPR render
- //
- int $doShadows = !$renderViewShadowsMode;
- int $doGlowPass = !$renderViewGlowPassMode;
-
-
- string $command;
- int $renderError;
-
- string $renderer;
-
- $renderer = currentRenderer();
-
- if (`renderer -query -iprRenderProcedure $renderer` != "")
- {
- $command = `renderer -query -iprRenderProcedure $renderer`;
- $renderError = catch(
- $result =
- `eval $command
- $resolution[0]
- $resolution[1]
- $doShadows
- $doGlowPass
- $camera`
- );
-
- string $currentRendererName = currentRenderer();
- string $renUIName = `renderer -query -rendererUIName $currentRendererName`;
- renderWindowEditor
- -edit
- -pca $renUIName
- $editor;
- }
- else
- {
- string $renUIName = `renderer -query -rendererUIName $renderer`;
- warning
- ("Current Renderer "
- + $renUIName
- + " does not support IPR");
- $renderError = true;
- }
-
- // Reset the IPR setting
- //
- setAttr ($globals[0] + ".createIprFile") $prevCreateIprFile;
- setAttr ($globals[0] + ".iprRenderShading") $prevIprRenderShading;
- setAttr ($globals[0] + ".iprRenderShadowMaps") $prevIprRenderShadowMaps;
- setAttr ($globals[0] + ".iprRenderMotionBlur") $prevIprRenderMotionBlur;
-
- if (!$renderError) {
- // Tell the IPR engine about the IPR file which has just
- // been created.
- //
- renderWindowLoadIprFileCallback($editor, $result, "");
-
- renderWindowRefreshLayout($editor);
-
- // Prompt the user to select a region to begin tuning
- //
- renderWindowEditor
- -edit
- -caption "Select a region to begin tuning"
- $editor;
-
- // If we have rendered an IPR image without motion blur, turn off
- // update motion blur on the IPR engine. Otherwise, set update
- // motion blur according to the user's choice in the IPR->IPR
- // Tuning Options menu.
- // If we didn't turn off update motion blur when there is no motion
- // blur, Pause IPR Tuning would prevent swatches from being updated.
- //
- if ($doBlur)
- {
- iprEngine -edit
- -updateMotionBlur `optionVar -query updateMotionBlur`
- defaultIprEngine;
- }
- else
- {
- iprEngine -edit
- -updateMotionBlur false
- defaultIprEngine;
- }
- }
- }
- else
- {
- int $prevCreateIprFile = `getAttr ($globals[0] + ".createIprFile")`;
- setAttr ($globals[0]+".createIprFile") false;
-
- int $doShadows = !$renderViewShadowsMode;
- int $doGlowPass = !$renderViewGlowPassMode;
-
- string $feature;
- string $command;
-
- string $renderer;
-
- $feature = "render";
- $renderer = currentRenderer();
-
- if (`renderer -query -renderProcedure $renderer` != "")
- {
- $command = `renderer -query -renderProcedure $renderer`;
-
- catch($result =
- `eval
- $command
- $resolution[0]
- $resolution[1]
- $doShadows
- $doGlowPass
- $camera`);
-
- string $currentRendererName = currentRenderer();
- string $renUIName = `renderer -query -rendererUIName $currentRendererName`;
- renderWindowEditor
- -edit
- -pca $renUIName
- $editor;
- }
- else
- {
- string $renUIName = `renderer -query -rendererUIName $renderer`;
- warning
- ("Current Renderer "
- + $renUIName
- + " does not support "
- + $feature);
- }
-
-
- setAttr ($globals[0] + ".createIprFile") $prevCreateIprFile;
- }
-
- optionVar -stringValue renderedImageName $result;
-
- // Reset the render region setting
- //
- setAttr ($globals[0] + ".useRenderRegion") $prevUseRenderRegion;
- }
-
- global proc renderWindowRender(
- string $renderMode,
- string $editor)
- {
- renderWindowRenderCamera($renderMode, $editor, "");
- }
-
- //
- // Description:
- // Take a snapshot by creating a temporary model editor whithin the
- // render view window.
- //
- global proc renderWindowTakeSnapshot
- ( int $resX,
- int $resY,
- string $camera )
- {
- //
- // Raise the render view in case it's partially covered.
- //
- raiseRenderViewWindow;
-
- string $prevParent = `setParent -q`;
- string $mainForm = `getRenderWindowPanelFormLayout`;
-
- setParent $mainForm;
-
- int $formX = `formLayout -q -w $mainForm`;
- int $formY = `formLayout -q -h $mainForm`;
- float $snapX = $resX;
- float $snapY = $resY;
-
- //
- // TODO: Not very clean, to be improved.
- //
- while( $snapX > $formX )
- {
- $snapX *= 0.8;
- $snapY *= 0.8;
- }
-
- while( $snapY > $formY )
- {
- $snapX *= 0.8;
- $snapY *= 0.8;
- }
-
- int $right = ($formX - $snapX);
- int $bottom = ($formY - $snapY);
-
- //
- // Create the model editor at the right size and take a snapshot.
- //
- modelEditor renderWindowTMPModelEditor;
-
- formLayout -e -af renderWindowTMPModelEditor left 0 $mainForm;
- formLayout -e -af renderWindowTMPModelEditor right $right $mainForm;
- formLayout -e -af renderWindowTMPModelEditor top 0 $mainForm;
- formLayout -e -af renderWindowTMPModelEditor bottom $bottom $mainForm;
-
- //
- // Unset camera gates and reset overscan to 1.
- //
- int $dfg = `camera -q -displayFilmGate $camera`;
- int $dr = `camera -q -displayResolution $camera`;
- float $os = `camera -q -overscan $camera`;
-
- camera -e -displayFilmGate off -displayResolution off -overscan 1.0 $camera;
-
- //
- // Set the right camera to the model editor.
- //
- modelEditor -e -cam $camera renderWindowTMPModelEditor;
-
- //
- // Ask the render window editor to take the snapshot of the given
- // modelEditor at the given resolution.
- //
- string $renderPanel = `getRenderWindowPanel`;
-
- renderWindowEditor -e -snp renderWindowTMPModelEditor $resX $resY $renderPanel;
-
- setParent $mainForm;
- deleteUI -ed renderWindowTMPModelEditor;
-
- //
- // Restore camera settings.
- //
- camera -e -displayFilmGate $dfg -displayResolution $dr -overscan $os $camera;
-
- //
- // Restore parent state.
- //
- setParent $prevParent;
- }
-
- global proc showRenderGlobals()
- {
- string $globals[] = `ls -renderGlobals`;
- showEditor $globals[0];
- }
-
- global proc switchAutoRenderRegionVar()
- {
- if( `optionVar -exists renderViewAutoRenderRegion` )
- {
- if( `optionVar -query renderViewAutoRenderRegion` != 0 )
- {
- optionVar -intValue renderViewAutoRenderRegion 0;
- }
- else
- {
- optionVar -intValue renderViewAutoRenderRegion 1;
- }
- }
- else
- {
- optionVar -intValue renderViewAutoRenderRegion 0;
- }
- }
-
- global proc switchAutoResizeVar( string $editor )
- {
- if( `optionVar -exists renderViewAutoResize` )
- {
- if( `optionVar -query renderViewAutoResize` != 0 )
- {
- optionVar -intValue renderViewAutoResize 0;
- }
- else
- {
- optionVar -intValue renderViewAutoResize 1;
- }
- }
- else
- {
- optionVar -intValue renderViewAutoResize 1;
- }
-
- $var = `optionVar -q renderViewAutoResize`;
-
- renderWindowEditor -e -ar $var $editor;
- }
-
- global proc switchShadowsVar( string $editor )
- {
- global int $renderViewShadowsMode;
-
- if ($renderViewShadowsMode)
- {
- $renderViewShadowsMode = 0;
- }
- else
- {
- $renderViewShadowsMode = 1;
- }
- }
-
- global proc switchGlowPassVar( string $editor )
- {
- global int $renderViewGlowPassMode;
-
- if ($renderViewGlowPassMode)
- {
- $renderViewGlowPassMode = 0;
- }
- else
- {
- $renderViewGlowPassMode = 1;
- }
- }
-
- global proc setTestResolutionVar( int $choice )
- {
- if( `optionVar -exists renderViewTestResolution` &&
- $choice >= 0 && $choice <= 4 )
- {
- optionVar -intValue renderViewTestResolution $choice;
- }
- else
- {
- //
- // Default is panel resolution.
- //
- optionVar -intValue renderViewTestResolution 1;
- }
- }
-
- proc loadSamples(string $editor)
- {
- // Determine what IPR sample type to load
- //
- string $sampleType;
-
- // Cancel the Hypershade snapshot if it is still going
- //
- if (`renderWindowEditor -query -snapshotMode $editor`) {
- renderWindowMenuCommand("grabSwatch", $editor);
- }
-
- // It can take awhile to load the samples, update the status line
- // in the render view so the user knows what is happening.
- //
-
- renderWindowEditor
- -edit
- -caption "Loading IPR Pixels..."
- $editor;
-
- int $startedTuning = catch(
- // Tell the IPR engine to start tuning
- //
- `iprEngine
- -edit
- -startTuning
- defaultIprEngine`
- );
-
- // Reset the caption.
- //
-
- renderWindowEditor
- -edit
- -caption ""
- $editor;
-
- // Update the memory estimate.
- //
- updateIPRMemoryEstimate();
- }
-
- global proc renderWindowMenuCommand(string $command, string $editor)
- //
- // This procedure acts as a command dispatcher. It is the single global
- // procedure which menu items need to call in order to effect commands. By
- // making this the single global point of entry, all of the implementation of
- // particular menu item commands can be put in local procedures and prevent
- // clutter in the global namespace.
- //
- {
- //
- // Call necessary procedures to effect the command and call the necessary
- // procedures to refresh the UI to reflect the results of the command.
- //
-
- if ($command == "loadImage")
- {
- loadImage($editor);
- renderWindowRefreshMenu("file", $editor);
- renderWindowRefreshLayout($editor);
- }
- else if ($command == "saveImage")
- {
- saveImage($editor);
- }
- else if ($command == "loadIprFile")
- {
- loadIprFile($editor);
- }
- else if ($command == "saveIprFile")
- {
- saveIprFile($editor);
- }
- else if ($command == "closeIprFile")
- {
- closeIprFile($editor);
- renderWindowRefreshLayout($editor);
- }
- else if ($command == "togglePauseTuning")
- {
- // Toggle IPR tuning on or off.
- //
- if (`iprEngine -exists defaultIprEngine`)
- {
- global int $gIprTuningPaused;
-
- if ($gIprTuningPaused)
- {
- // Tuning is currently paused, so we will unpause it by
- // reenabling updating according to the current settings of
- // the optionVars which specify which updating should be done.
- //
- iprEngine
- -edit
- -updateShading
- (`optionVar -query updateShadingAndLighting`)
- defaultIprEngine;
- iprEngine
- -edit
- -updateLightGlow (`optionVar -query updateLightGlow`)
- defaultIprEngine;
- iprEngine
- -edit
- -updateShaderGlow (`optionVar -query updateShaderGlow`)
- defaultIprEngine;
- iprEngine
- -edit
- -updateMotionBlur (`optionVar -query updateMotionBlur`)
- defaultIprEngine;
-
- $gIprTuningPaused = false;
- }
- else
- {
- // Tuning is currently unpaused, so we will pause it by
- // disabling updating of the various aspects of an IPR image.
- //
- iprEngine
- -edit
- -updateShading false
- defaultIprEngine;
- iprEngine
- -edit
- -updateLightGlow false
- defaultIprEngine;
- iprEngine
- -edit
- -updateShaderGlow false
- defaultIprEngine;
- iprEngine
- -edit
- -updateMotionBlur false
- defaultIprEngine;
-
- $gIprTuningPaused = true;
- }
- }
-
- // Issue a refresh so that the pause button on the toolbar is properly
- // updated.
- //
- renderWindowRefreshLayout($editor);
- renderWindowRefreshMenu("ipr", $editor);
- }
- else if ($command == "keepImageInRenderView")
- {
- int $currImage = `renderWindowEditor -q -displayImage $editor`;
-
- if ($currImage < 0)
- {
- renderWindowEditor -edit -saveImage $editor;
- renderWindowRefreshMenu("file", $editor);
- renderWindowRefreshLayout($editor);
- }
- else
- {
- warning("This image is already kept.");
- }
- }
- else if ($command == "removeImageFromRenderView")
- {
- int $currImage = `renderWindowEditor -q -displayImage $editor`;
-
- if ($currImage >= 0)
- {
- renderWindowEditor -edit -removeImage $editor;
- renderWindowRefreshMenu("file", $editor);
- renderWindowRefreshLayout($editor);
- }
- else
- {
- warning((
- "Cannot remove the current image from the renderview."
- + " Choose a stored image instead."));
- }
- }
- else if ($command == "updateShadowMaps")
- {
- if (isIprFileLoaded())
- {
- iprEngine -edit -updateShadowMaps defaultIprEngine;
- }
- }
- else if ($command == "loadSamples")
- {
- loadSamples($editor);
- }
- else if ($command == "refreshIprImage")
- {
- refreshIprImage();
- }
- else if ($command == "updateShadingAndLighting")
- {
- optionVar
- -intValue updateShadingAndLighting (!`optionVar -query updateShadingAndLighting`);
- if (`iprEngine -query -exists defaultIprEngine`)
- {
- iprEngine
- -edit
- -updateShading (`optionVar -query updateShadingAndLighting`)
- defaultIprEngine;
- }
- renderWindowRefreshMenu("ipr", $editor);
- }
- else if ($command == "updateLightGlow")
- {
- optionVar
- -intValue updateLightGlow (!`optionVar -query updateLightGlow`);
- if (`iprEngine -query -exists defaultIprEngine`)
- {
- iprEngine
- -edit
- -updateLightGlow (`optionVar -query updateLightGlow`)
- defaultIprEngine;
- renderWindowRefreshMenu("ipr", $editor);
- }
- }
- else if ($command == "updateShaderGlow")
- {
- optionVar
- -intValue updateShaderGlow (!`optionVar -query updateShaderGlow`);
- if (`iprEngine -query -exists defaultIprEngine`)
- {
- iprEngine
- -edit
- -updateShaderGlow (`optionVar -query updateShaderGlow`)
- defaultIprEngine;
- renderWindowRefreshMenu("ipr", $editor);
- }
- }
- else if ($command == "updateMotionBlur")
- {
- optionVar
- -intValue updateMotionBlur (!`optionVar -query updateMotionBlur`);
- if (`iprEngine -query -exists defaultIprEngine`)
- {
- iprEngine
- -edit
- -updateMotionBlur (`optionVar -query updateMotionBlur`)
- defaultIprEngine;
- renderWindowRefreshMenu("ipr", $editor);
- }
- }
- else if ($command == "showRegionMarquee")
- {
- string $camera = `getCurrentCamera`;
- string $panel = `getCameraPanel( $camera )`;
- int $res[] = `getTestResolution( $panel )`;
-
- renderWindowEditor
- -edit
- -showRegion $res[0] $res[1]
- $editor;
- }
- else if ($command == "dithered")
- {
- int $singleBuffer = `renderWindowEditor -query -singleBuffer $editor`;
-
- if ($singleBuffer == 0)
- {
- renderWindowEditor
- -edit
- -singleBuffer
- $editor;
- }
- else
- {
- renderWindowEditor
- -edit
- -doubleBuffer
- $editor;
- }
- }
- else if ($command == "toolbar")
- {
- toggleDisplayToolbar();
- renderWindowRefreshLayout($editor);
- }
- else if ($command == "grabSwatch")
- {
- if (`renderWindowEditor -query -snapshotMode $editor`) {
- // The user is already in grab swatch mode, so we will get out of
- // grab swatch mode.
- //
- renderWindowEditor -edit -caption "" $editor;
- renderWindowEditor -edit -snapshotMode off $editor;
- } else {
- // We will enter grab swatch mode.
- //
- renderWindowEditor
- -edit
- -caption "Select a region and drag it to a swatch in Hypershade"
- $editor;
- renderWindowEditor -edit -snapshotMode on $editor;
- }
- }
- }
-
-
-
- //----------------------------------------------------------------------------//
- // Procedures which generate menu items and procedures which refresh menus
- // when they are opened
- //----------------------------------------------------------------------------//
-
- proc createFileMenu(string $editor, string $menuType)
- {
- if ($menuType == "popup")
- {
- menuItem
- -label "File"
- -subMenu true
- -postMenuCommand
- ("renderWindowRefreshMenu "
- + "\"file\" "
- + $editor)
- -familyImage ""
- ($editor + $menuType + "FileMenu");
- }
- else
- {
- menu
- -label "File"
- -tearOff true
- -postMenuCommand
- ("renderWindowRefreshMenu "
- + "\"file\" "
- + $editor)
- -familyImage ""
- ($editor + $menuType + "FileMenu");
- }
-
- menuItem
- -label "Open Image..."
- -command
- ("renderWindowMenuCommand loadImage " + $editor)
- -annotation
- "Load an image from disk."
- ($editor + "loadImageItem");
-
- menuItem
- -label "Save Image..."
- -command
- ("renderWindowMenuCommand saveImage " + $editor)
- -annotation
- "Save the currently displayed image to disk."
- ($editor + "saveImageItem");
-
- menuItem
- -divider true;
-
- menuItem
- -label "Open IPR File..."
- -command
- ("renderWindowMenuCommand loadIprFile " + $editor)
- -annotation
- "Load an IPR file from disk."
- ($editor + "loadIprFileItem");
-
- menuItem
- -label "Save IPR File..."
- -command
- ("renderWindowMenuCommand saveIprFile " + $editor)
- -annotation
- "Save an IPR file to disk."
- ($editor + "saveIprFileItem");
-
- menuItem
- -label "Close IPR File..."
- -command
- ("renderWindowMenuCommand closeIprFile " + $editor)
- -annotation
- "Finish your IPR session with the current IPR file."
- ($editor + "closeIprFileItem");
-
- menuItem
- -divider true;
-
- menuItem -label "Render Diagnostics..."
- -annotation (getRunTimeCommandAnnotation("RenderDiagnostics"))
- -command ("RenderDiagnostics")
- ($editor + "renderDiagnosticsItem");
-
- menuItem
- -divider true;
-
- menuItem
- -label "Keep Image in Render View"
- -command
- ("renderWindowMenuCommand keepImageInRenderView " + $editor)
- -annotation
- "Temporarily save the currently displayed image in Maya's image buffer."
- ($editor + "keepImageInRenderViewItem");
-
- menuItem
- -label "Remove Image from Render View"
- -command
- ("renderWindowMenuCommand removeImageFromRenderView " + $editor)
- -annotation
- "Remove the currently displayed image from Maya's image buffer."
- ($editor + "removeImageFromRenderViewItem");
-
- setParent -menu ..; // from FileMenu
- }
-
- proc refreshFileMenu(string $editor, string $menuType)
- {
- setParent -menu ($editor + $menuType + "FileMenu");
-
- // If there is no image or IPR image currently in the renderview, dim the
- // Save Image... item, the Keep Image in Render View item and the Remove
- // Image from Render View item.
- //
- if (isImageLoaded($editor))
- {
- menuItem
- -edit
- -enable true
- ($editor + "saveImageItem");
- menuItem
- -edit
- -enable true
- ($editor + "keepImageInRenderViewItem");
- }
- else
- {
- menuItem
- -edit
- -enable false
- ($editor + "saveImageItem");
- menuItem
- -edit
- -enable false
- ($editor + "keepImageInRenderViewItem");
- }
-
- // If current renderer supports IPR
- //
- string $currentRendererName = currentRenderer();
- if (`renderer -query -iprRenderProcedure $currentRendererName` != "")
- {
- // Enable load ipr file menuitem if ipr is supported
- //
- menuItem
- -edit
- -enable true
- ($editor + "loadIprFileItem");
-
- // If there is no IPR file currently in the renderview, dim the Save IPR
- // File... item.
- //
- if (isIprFileLoaded())
- {
- menuItem
- -edit
- -enable true
- ($editor + "saveIprFileItem");
-
- menuItem
- -edit
- -enable true
- ($editor + "closeIprFileItem");
- }
- else
- {
- menuItem
- -edit
- -enable false
- ($editor + "saveIprFileItem");
-
- menuItem
- -edit
- -enable false
- ($editor + "closeIprFileItem");
- }
- }
- else
- {
- menuItem
- -edit
- -enable false
- ($editor + "loadIprFileItem");
-
-
- menuItem
- -edit
- -enable false
- ($editor + "saveIprFileItem");
-
- menuItem
- -edit
- -enable false
- ($editor + "closeIprFileItem");
-
- }
-
-
- // If current renderer supports renderdiagnostics, disable/enable
- // related UI
- //
- string $currentRendererName = currentRenderer();
- if (`renderer -query -renderDiagnosticsProcedure $currentRendererName` != "")
- {
- menuItem
- -edit
- -enable true
- ($editor + "renderDiagnosticsItem");
- }
- else
- {
- menuItem
- -edit
- -enable false
- ($editor + "renderDiagnosticsItem");
- }
- // If the renderview is currently looking at the non-buffered image, dim
- // the Remove Image from Render View item.
- //
- if (`renderWindowEditor -query -displayImage $editor` >= 0)
- {
- menuItem
- -edit
- -enable true
- ($editor + "removeImageFromRenderViewItem");
- }
- else
- {
- menuItem
- -edit
- -enable false
- ($editor + "removeImageFromRenderViewItem");
- }
- }
-
- proc createRenderMenu(string $editor, string $menuType)
- {
- // Create the Render menu
- //
- if ($menuType == "popup")
- {
- menuItem
- -subMenu true
- -label "Render"
- -postMenuCommand
- ("renderWindowRefreshMenu "
- + "\"render\" "
- + $editor)
- -familyImage "menuIconRender.xpm"
- ($editor + $menuType + "RenderMenu");
- }
- else
- {
- menu
- -label "Render"
- -tearOff true
- -postMenuCommand
- ("renderWindowRefreshMenu "
- + "\"render\" "
- + $editor)
- -familyImage "menuIconRender.xpm"
- ($editor + $menuType + "RenderMenu");
- }
-
- menuItem
- -label "Redo Previous Render"
- -command
- ("renderWindowRender redoPreviousRender " + $editor)
- -annotation
- "Render using the camera used to do the previous render."
- ($editor + "redoPreviousRenderItem");
-
- menuItem
- -label "Render Region"
- -command
- ("renderWindowRenderRegion " + $editor)
- -annotation
- "Render the part of the image contained within the region marquee."
- ($editor + "renderRegionItem");
-
- menuItem
- -divider true;
-
- //
- // Dynamic render menu, it contains the list of cameras to render
- // from.
- //
- menuItem
- -label "Render"
- -subMenu true
- -tearOff true
- ($editor + $menuType + "renderRenderItem");
- menuItem
- -edit
- -postMenuCommand
- ("renderWindowCreateCameraSubmenu "
- + $editor
- + $menuType
- + "renderRenderItem"
- + " "
- + "\"renderWindowRenderCamera render "
- + $editor
- + " \""
- + $editor)
- -annotation
- "Render using a particular camera."
- ($editor + $menuType + "renderRenderItem");
- setParent -menu ..; // from Render menu
-
- //
- // Dynamic snapshot render menu, it contains the list of visible
- // camera panels to render from.
- //
- menuItem
- -label "Snapshot"
- -subMenu true
- -tearOff true
- ($editor + $menuType + "renderSnapshotItem");
- menuItem
- -edit
- -postMenuCommand
- ("renderWindowCreateCameraSubmenu "
- + $editor
- + $menuType
- + "renderSnapshotItem"
- + " "
- + "\"renderWindowRenderCamera snapshot "
- + $editor
- + " \""
- + $editor)
- -annotation
- "Take a wireframe snapshot using a particular camera."
- ($editor + $menuType + "renderSnapshotItem");
- setParent -menu ..; // from Snapshot menu
-
- setParent -menu ..; // from Render menu
- }
-
- proc refreshRenderMenu(string $editor, string $menuType)
- {
- setParent -menu ($editor + $menuType + "RenderMenu");
- }
-
- proc createIprMenu(string $editor, string $menuType)
- {
- // Create the IPR menu
- //
- if ($menuType == "popup")
- {
- menuItem
- -subMenu true
- -label "IPR"
- -postMenuCommand
- ("renderWindowRefreshMenu "
- + "\"ipr\" "
- + $editor)
- -familyImage ""
- ($editor + $menuType + "IprMenu");
- }
- else
- {
- menu
- -label "IPR"
- -tearOff true
- -postMenuCommand
- ("renderWindowRefreshMenu "
- + "\"ipr\" "
- + $editor)
- -familyImage ""
- ($editor + $menuType + "IprMenu");
- }
-
- menuItem
- -label "Redo Previous IPR Render"
- -command
- ("renderWindowRender redoPreviousIprRender " + $editor)
- -annotation
- "IPR Render using the camera used to do the previous render."
- ($editor + "redoPreviousIprRenderItem");
-
- menuItem
- -divider true;
-
- //
- // Dynamic render menu, it contains the list of cameras to render
- // from.
- //
- menuItem
- -label "IPR Render"
- -subMenu true
- -tearOff true
- ($editor + $menuType + "iprRenderItem");
- menuItem
- -edit
- -postMenuCommand
- ("renderWindowCreateCameraSubmenu "
- + $editor
- + $menuType
- + "iprRenderItem "
- + "\"renderWindowRenderCamera iprRender "
- + $editor
- + " \""
- + $editor)
- -annotation
- "Render using a particular camera."
- ($editor + $menuType + "iprRenderItem");
- setParent -menu ..; // from Render menu
-
- menuItem
- -divider true;
-
- menuItem
- -label "Update Shadow Maps"
- -command
- ("renderWindowMenuCommand updateShadowMaps " + $editor)
- -annotation
- ("Re-create shadow maps for specific lights. "
- + "(Required after lights change position etc.)")
- ($editor + "updateShadowMapsItem");
-
- menuItem
- -label "Update Image Planes/Background"
- -command
- ("renderWindowMenuCommand loadSamples " + $editor)
- -annotation
- ("Re-load IPR pixels in the marquee region. Required after "+
- "adjusting image planes.")
- ($editor + "loadSamplesItem");
-
- menuItem
- -label "Refresh IPR Image"
- -command
- ("renderWindowMenuCommand refreshIprImage " + $editor)
- -annotation
- ("Refresh the ipr image tile-by-tile.")
- ($editor + "refreshIprImage");
-
- menuItem
- -label "IPR Tuning Options"
- -subMenu true
- -tearOff true
- ($editor + "iprUpdateOptionsItem");
-
- menuItem
- -enable false
- -label "Update Shading and Lighting"
- -checkBox true
- -annotation
- ("When checked, changes to shading or lighting parameters "+
- "will be shown in the interactive IPR render.")
- -command
- ("renderWindowMenuCommand updateShadingAndLighting " + $editor)
- ($editor + "updateShadingAndLightingItem");
-
- menuItem
- -label "Update Shader Glow"
- -checkBox true
- -annotation
- ("When checked, changes to shader glow parameters "+
- "will be shown in the interactive IPR render.")
- -command
- ("renderWindowMenuCommand updateShaderGlow " + $editor)
- ($editor + "updateShaderGlowItem");
-
- menuItem
- -label "Update Light Glow"
- -checkBox true
- -annotation
- ("When checked, changes to light glow parameters "+
- "will be shown in the interactive IPR render.")
- -command
- ("renderWindowMenuCommand updateLightGlow " + $editor)
- ($editor + "updateLightGlowItem");
-
- menuItem
- -label "Update 2D Motion Blur"
- -checkBox true
- -annotation
- ("When checked, changes to 2D motion blur parameters "+
- "will be shown in the interactive IPR render.")
- -command
- ("renderWindowMenuCommand updateMotionBlur " + $editor)
- ($editor + "updateMotionBlurItem");
-
- setParent -menu ..; // from IPR Tuning Options
-
- menuItem
- -divider true;
-
- global int $gIprTuningPaused;
-
- menuItem
- -label "Pause IPR Tuning"
- -checkBox $gIprTuningPaused
- -command
- ("renderWindowMenuCommand togglePauseTuning " + $editor)
- -annotation
- ("Pause/unpause IPR tuning.")
- ($editor + "pauseIprTuning");
-
- setParent -menu ..; // from IPR menu
- }
-
- proc refreshIprMenu(string $editor, string $menuType)
- {
- setParent -menu ($editor + $menuType + "IprMenu");
-
- global int $gIprTuningPaused;
-
- string $currentRendererName = currentRenderer();
- if (`renderer -query -iprRenderProcedure $currentRendererName` != "")
- {
-
- string $iprMenuItems[] = `menu -query -itemArray ($editor + $menuType + "IprMenu")`;
- //
- // Enable ipr menuItems if renderer supports the ipr feature.
- // These items have to be explicitly enabled in case they were
- // disabled by the previous renderer
- //
- for ($i = 0; $i < size($iprMenuItems); $i += 1)
- {
- menuItem -edit -enable true $iprMenuItems[$i];
- }
-
- if (isIprFileLoaded())
- {
- menuItem
- -edit
- -enable true
- ($editor + "updateShadowMapsItem");
-
- menuItem
- -edit
- -enable true
- ($editor + "loadSamplesItem");
-
- menuItem
- -edit
- -enable (!$gIprTuningPaused)
- ($editor + "refreshIprImage");
-
- menuItem
- -edit
- -enable true
- ($editor + "iprUpdateOptionsItem");
-
- menuItem
- -edit
- -enable true
- ($editor + "pauseIprTuning");
- }
- else
- {
- menuItem
- -edit
- -enable false
- ($editor + "updateShadowMapsItem");
-
- menuItem
- -edit
- -enable false
- ($editor + "loadSamplesItem");
-
- menuItem
- -edit
- -enable false
- ($editor + "refreshIprImage");
-
- menuItem
- -edit
- -enable false
- ($editor + "iprUpdateOptionsItem");
-
- menuItem
- -edit
- -enable false
- ($editor + "pauseIprTuning");
- }
-
- // Check or uncheck the "Pause IPR Tuning" menu item checkbox
- // appropriately
- //
- menuItem
- -edit
- -checkBox $gIprTuningPaused
- ($editor + "pauseIprTuning");
-
- if (isIprFileLoaded())
- {
- // Only allow the user to modify settings which will have an effect.
- // If, for example, the currently loaded IPR file does not contain
- // samples needed for shading and lighting tuning, then disable the
- // shading and lighting option.
- //
- int $shadingAndLightingAvailable = true;
- int $lightGlowAvailable = isIprFileLoaded();
- int $shaderGlowAvailable = isIprFileLoaded();
-
- int $motionBlurAvailable = false;
- string $motionVectorFile[] = `iprEngine -q -motionVectorFile defaultIprEngine`;
- if (size($motionVectorFile) > 0)
- if ($motionVectorFile[0] != "")
- $motionBlurAvailable = true;
-
- menuItem
- -edit
- -checkBox ($shadingAndLightingAvailable && `optionVar -query updateShadingAndLighting`)
- -enable $shadingAndLightingAvailable
- ($editor + "updateShadingAndLightingItem");
-
- menuItem
- -edit
- -checkBox ($lightGlowAvailable && `optionVar -query updateLightGlow`)
- -enable $lightGlowAvailable
- ($editor + "updateLightGlowItem");
-
- menuItem
- -edit
- -checkBox ($shaderGlowAvailable && `optionVar -query updateShaderGlow`)
- -enable $shaderGlowAvailable
- ($editor + "updateShaderGlowItem");
-
- menuItem
- -edit
- -checkBox ($motionBlurAvailable && `optionVar -query updateMotionBlur`)
- -enable $motionBlurAvailable
- ($editor + "updateMotionBlurItem");
- }
- }
- else
- {
- string $iprMenuItems[] = `menu -query -itemArray ($editor + $menuType + "IprMenu")`;
-
- // Disable all ipr menuItems if current renderer does not support ipr.
- // Since the menu itself cannot be disabled, all menuItems are being
- // greyed out
- //
- for ($i = 0; $i < size($iprMenuItems); $i += 1)
- {
- menuItem -edit -enable false $iprMenuItems[$i];
- }
- }
- }
-
-
- proc createOptionsMenu(string $editor, string $menuType)
- {
- string $subName;
-
- if ($menuType == "popup")
- {
- menuItem
- -subMenu true
- -label "Options"
- -postMenuCommand
- ("renderWindowRefreshMenu "
- + "\"options\" "
- + $editor)
- -familyImage "menuIconRenderSettings.xpm"
- ($editor + $menuType + "OptionsMenu");
- }
- else
- {
- menu
- -label "Options"
- -tearOff true
- -postMenuCommand
- ("renderWindowRefreshMenu "
- + "\"options\" "
- + $editor)
- -familyImage "menuIconRenderSettings.xpm"
- ($editor + $menuType + "OptionsMenu");
- }
-
- setParent -menu ..; // from Options menu
- }
-
- proc buildOptionsMenu(string $editor, string $menuType)
- {
- // Create a render globals menu item for each available renderer
- //
- int $i;
- string $rendererUIName = "";
- string $command = "displayRenderGlobalsWindow";
-
- if ($command != "")
- {
- menuItem
- -enableCommandRepeat false
- -label "Render Globals ..."
- -annotation "Render Globals: Change global rendering attributes"
- -command $command;
- }
-
- menuItem
- -subMenu true
- -label "Render using"
- -annotation
- "Change current renderer"
- ($editor + $menuType + "renderUsingItem");
-
- menuItem
- -edit
- -postMenuCommand
- ("buildRenderUsingMenu "
- + $editor
- + $menuType + "renderUsingItem "
- + $editor)
- ($editor + $menuType + "renderUsingItem");
-
- setParent -menu ..;
-
- menuItem -divider true;
-
-
- menuItem
- -subMenu true
- -label "Test Resolution"
- -annotation
- "Change the resolution of test renders."
- ($editor + $menuType + "resolutionItem");
-
- menuItem
- -edit
- -postMenuCommand
- ("renderWindowMakeResolutionItem "
- + $editor
- + $menuType + "resolutionItem "
- + $editor)
- ($editor + $menuType + "resolutionItem");
-
- setParent -menu ..; // from Resolution menu
-
- menuItem -divider true;
-
- menuItem
- -label "Auto Resize"
- -checkBox false
- -command ("switchAutoResizeVar " + $editor)
- -annotation
- ("When checked, each new test render will automatically be resized "
- + "to real size and centered on the screen.")
- ($editor + "autoResizeItem");
-
- menuItem
- -label "Auto Render Region"
- -checkBox false
- -command "switchAutoRenderRegionVar"
- -annotation
- ("When checked, a Render Region will automatically begin as soon "
- + "as you finish marqueeing a region.")
- ($editor + "autoRenderRegionItem");
-
-
- menuItem -divider true;
-
- menuItem
- -label "Ignore Shadows"
- -checkBox false
- -command ("switchShadowsVar " + $editor)
- -annotation
- ("When checked, no shadows will be rendered")
- ($editor + "shadowsItem");
-
- menuItem
- -label "Ignore Glows"
- -checkBox false
- -command ("switchGlowPassVar " + $editor)
- -annotation
- ("When checked, no glow pass will be rendered")
- ($editor + "glowPassItem");
- }
-
- proc refreshOptionsMenu(string $editor, string $menuType)
- {
- global int $renderViewShadowsMode;
- global int $renderViewGlowPassMode;
-
- setParent -menu ($editor + $menuType + "OptionsMenu");
-
- menu
- -edit
- -deleteAllItems
- ($editor + $menuType + "OptionsMenu");
-
- buildOptionsMenu($editor, $menuType);
-
- // If auto resize is on, check the Auto Resize checkbox.
- //
- menuItem
- -edit
- -checkBox `optionVar -query renderViewAutoResize`
- ($editor + "autoResizeItem");
-
- menuItem
- -edit
- -checkBox $renderViewShadowsMode
- ($editor + "shadowsItem");
-
- menuItem
- -edit
- -checkBox $renderViewGlowPassMode
- ($editor + "glowPassItem");
-
- // Make sure the state of the renderWindowEditor accurately reflects the
- // user's setting of the optionVar
- //
- renderWindowEditor
- -edit
- -autoResize `optionVar -query renderViewAutoResize`
- $editor;
-
- // If auto render region is on, check the Auto Render Region checkbox.
- //
- menuItem
- -edit
- -enable true
- -checkBox `optionVar -query renderViewAutoRenderRegion`
- ($editor + "autoRenderRegionItem");
-
- string $currentRendererName = currentRenderer();
- if (`renderer -query -iprRenderProcedure $currentRendererName` != "")
- {
- // Disable this menu item for IPR
- if (isIprFileLoaded()) {
- menuItem -edit -enable false
- ($editor + "autoRenderRegionItem");
- }
-
- // Disable these menu items for IPR
- if (isIprFileLoaded()) {
- menuItem -edit -enable false ($editor + "shadowsItem");
- menuItem -edit -enable false ($editor + "glowPassItem");
- } else {
- menuItem -edit -enable true ($editor + "shadowsItem");
- menuItem -edit -enable true ($editor + "glowPassItem");
- }
- }
- else
- {
- menuItem -edit -enable false ($editor + "shadowsItem");
- menuItem -edit -enable false ($editor + "glowPassItem");
- }
- }
-
- proc createViewMenu(string $editor, string $menuType)
- {
- if ($menuType == "popup")
- {
- menuItem
- -subMenu true
- -label "View"
- -postMenuCommand
- ("renderWindowRefreshMenu "
- + "\"view\" "
- + $editor)
- -familyImage "menuIconView.xpm"
- ($editor + $menuType + "ViewMenu");
- }
- else
- {
- menu
- -label "View"
- -tearOff true
- -postMenuCommand
- ("renderWindowRefreshMenu "
- + "\"view\" "
- + $editor)
- -familyImage "menuIconView.xpm"
- ($editor + $menuType + "ViewMenu");
- }
-
- menuItem
- -label "Frame Image"
- -command
- ("renderWindowEditor "
- + "-edit "
- + "-frameImage "
- + $editor)
- -annotation
- "Zoom the image so it just fits in the render view."
- ($editor + "frameImageItem");
-
- menuItem
- -label "Frame Region"
- -command
- ("renderWindowEditor "
- + "-edit "
- + "-frameRegion "
- + $editor)
- -annotation
- "Zoom the region so it just fits in the render view."
- ($editor + "frameRegionItem");
-
- menuItem
- -label "Real Size"
- -command
- ("renderWindowEditor "
- + "-edit "
- + "-realSize "
- + $editor)
- -annotation
- "Zoom the image so it is displayed at its real size."
- ($editor + "realSizeItem");
-
- menuItem -divider true;
-
- menuItem
- -label "Show Region Marquee"
- -command ("renderWindowMenuCommand showRegionMarquee " + $editor)
- -annotation
- "Show the region marquee."
- ($editor + "showRegionMarqueeItem");
-
- menuItem
- -label "Reset Region Marquee"
- -command
- ("renderWindowEditor "
- + "-edit "
- + "-marquee 1.0 0.0 0.0 1.0 "
- + $editor)
- -annotation
- "Reset the region to be the size of the entire image."
- ($editor + "resetRegionMarqueeItem");
-
- menuItem -divider true;
-
- menuItem
- -label "Grab Swatch to Hypershade/Visor"
- -command ("renderWindowMenuCommand grabSwatch " + $editor)
- -annotation "Grab Swatch to Hypershade/Visor"
- ($editor + "grabSwatchItem");
-
- setParent -menu ..; // from View menu
- }
-
- proc refreshViewMenu(string $editor, string $menuType)
- {
- //
- // Set the appropriate text for the grab swatch
- //
- if ($menuType == "menubar") {
- setParent -menu ($editor + $menuType + "ViewMenu");
- } else if ($menuType == "popup") {
- setParent -menu ($editor + $menuType + "OptionsMenu");
- }
- if (`renderWindowEditor -query -snapshotMode $editor`) {
- menuItem -edit
- -label "Cancel Swatch Grab to Hypershade/Visor"
- -annotation "Cancel Swatch Grab to Hypershade/Visor"
- ($editor + "grabSwatchItem");
- } else {
- menuItem -edit
- -label "Grab Swatch to Hypershade/Visor"
- -annotation "Grab Swatch to Hypershade/Visor"
- ($editor + "grabSwatchItem");
- }
- }
-
- proc refreshDisplayMenu(string $editor, string $menuType)
- {
- setParent -menu ($editor + $menuType + "DisplayMenu");
-
- // Check the display style and color channel information.
- //
- string $displayStyle = `renderWindowEditor -q -displayStyle $editor`;
- float $scaleRed = `renderWindowEditor -q -scaleRed $editor`;
- float $scaleGreen = `renderWindowEditor -q -scaleGreen $editor`;
- float $scaleBlue = `renderWindowEditor -q -scaleBlue $editor`;
- int $isColor = ($displayStyle == "color");
- int $isRed = $isColor && ($scaleRed == 1.0);
- int $isGreen = $isColor && ($scaleGreen == 1.0);
- int $isBlue = $isColor && ($scaleBlue == 1.0);
-
- // Update the display style and color channel radioButton menuItems.
- //
- menuItem -edit
- -radioButton ($isRed && !$isBlue && !$isGreen)
- ($editor + "redPlaneItem");
-
- menuItem -edit
- -radioButton (!$isRed && !$isBlue && $isGreen)
- ($editor + "greenPlaneItem");
-
- menuItem -edit
- -radioButton (!$isRed && $isBlue && !$isGreen)
- ($editor + "bluePlaneItem");
-
- menuItem -edit
- -radioButton ($isColor && $isRed && $isGreen && $isBlue )
- ($editor + "allPlanesItem");
-
- menuItem -edit
- -radioButton (!$isColor && ($displayStyle == "lum"))
- ($editor + "luminanceItem");
-
- menuItem -edit
- -radioButton (!$isColor && ($displayStyle == "mask"))
- ($editor + "maskPlaneItem");
-
- // Update the dithered menuItem
- //
- int $dithered = !`renderWindowEditor -query -singleBuffer $editor`;
- menuItem -edit -checkBox $dithered ($editor + "ditheredItem");
-
- // Update the toolbar menuItem
- //
- if (isToolbarDisplayed())
- {
- menuItem
- -edit
- -checkBox true
- ($editor + "toolbarItem");
- }
- else
- {
- menuItem
- -edit
- -checkBox false
- ($editor + "toolbarItem");
- }
- }
-
-
- // Description: This procedure is called to create both the
- // "Display" pulldown menu in render view window and the
- // right mouse button click tear off window --> "Display"
- // meanu.
- //
- proc createDisplayMenu(string $editor, string $menuType)
- {
- if ($menuType == "popup")
- {
- menuItem
- -subMenu true
- -label "Display"
- -postMenuCommand
- ("renderWindowRefreshMenu "
- + "\"display\" "
- + $editor)
- -familyImage "menuIconDisplay.xpm"
- ($editor + $menuType + "DisplayMenu");
- }
- else
- {
- menu
- -label "Display"
- -tearOff true
- -postMenuCommand
- ("renderWindowRefreshMenu "
- + "\"display\" "
- + $editor)
- -familyImage "menuIconDisplay.xpm"
- ($editor + $menuType + "DisplayMenu");
- }
-
- radioMenuItemCollection ("renderWindowPlanesCollection" + $menuType);
-
- menuItem
- -label "Red Channel"
- -radioButton false
- -collection ("renderWindowPlanesCollection" + $menuType)
- -command
- ("renderWindowEditor "
- + "-edit "
- + "-displayStyle \"color\" "
- + "-scaleRed 1 "
- + "-scaleGreen -1000 "
- + "-scaleBlue -1000 "
- + $editor )
- -annotation
- "Display the red channel only."
- ($editor + "redPlaneItem");
-
- menuItem
- -label "Green Channel"
- -radioButton false
- -collection ("renderWindowPlanesCollection" + $menuType)
- -command
- ("renderWindowEditor "
- + "-edit "
- + "-displayStyle \"color\" "
- + "-scaleRed -1000 "
- + "-scaleGreen 1 "
- + "-scaleBlue -1000 "
- + $editor )
- -annotation
- "Display the green channel only."
- ($editor + "greenPlaneItem");
-
- menuItem
- -label "Blue Channel"
- -radioButton false
- -collection ("renderWindowPlanesCollection" + $menuType)
- -command
- ("renderWindowEditor "
- + "-edit "
- + "-displayStyle \"color\" "
- + "-scaleRed -1000 "
- + "-scaleGreen -1000 "
- + "-scaleBlue 1 "
- + $editor )
- -annotation
- "Display the blue channel only."
- ($editor + "bluePlaneItem");
-
- menuItem
- -label "All Channels"
- -radioButton true
- -collection ("renderWindowPlanesCollection" + $menuType)
- -command
- ("renderWindowEditor "
- + "-edit "
- + "-displayStyle \"color\" "
- + "-scaleRed 1 "
- + "-scaleGreen 1 "
- + "-scaleBlue 1 "
- + $editor )
- -annotation
- "Display the red, green and blue channels of the image together."
- ($editor + "allPlanesItem");
-
- menuItem -divider true;
-
- menuItem
- -label "Luminance"
- -radioButton false
- -collection ("renderWindowPlanesCollection" + $menuType)
- -command
- ("renderWindowEditor "
- + "-edit "
- + "-displayStyle \"lum\" "
- + $editor )
- -annotation
- "Display the luminance of the image."
- ($editor + "luminanceItem");
-
- menuItem
- -label "Alpha Channel"
- -radioButton false
- -collection ("renderWindowPlanesCollection" + $menuType)
- -command
- ("renderWindowEditor "
- + "-edit "
- + "-displayStyle \"mask\" "
- + $editor )
- -annotation
- "Display the alpha channel of the image."
- ($editor + "maskPlaneItem");
-
- menuItem -divider true;
-
- menuItem
- -label "Dithered"
- -checkBox true
- -command
- ("renderWindowMenuCommand dithered " + $editor)
- -annotation
- ("Checked, image is displayed dithered but smooth "
- + "scrolling. Unchecked, image is displayed undithered but "
- + "flashes when scrolling.")
- ($editor + "ditheredItem");
-
- menuItem -divider true;
-
- menuItem
- -label "Toolbar"
- -checkBox true
- -command
- ("renderWindowMenuCommand toolbar " + $editor)
- -annotation
- "Show or hide the toolbar."
- ($editor + "toolbarItem");
-
- setParent -menu ..; // from Display menu
-
- // update the menuItem information.
- //
- refreshDisplayMenu($editor, $menuType);
- }
-
- global proc renderWindowMakeResolutionItem
- ( string $subMenuName,
- string $panelName )
- {
- popupMenu -e -deleteAllItems $subMenuName;
- setParent -m $subMenuName;
-
- //
- // Use panel resolution item.
- //
- int $testRes = `optionVar -q renderViewTestResolution`;
- int $panelBool = ( $testRes == 0 );
- int $fullBool = ( $testRes == 1 );
- int $halfBool = ( $testRes == 2 );
- int $quaterBool = ( $testRes == 3 );
- int $tenthBool = ( $testRes == 4 );
- int $res[] = `getGlobalsResolution`;
-
- menuItem -l "Camera Panel"
- -cb $panelBool
- -c "setTestResolutionVar(0)"
- ($panelName + "panelResolutionItem");
-
- menuItem -l ("Render Globals (" + $res[0] + "x" + $res[1] + ")")
- -cb $fullBool
- -c "setTestResolutionVar(1)"
- ($panelName + "fullResolutionItem");
-
- $x = $res[0] / 2;
- $y = $res[1] / 2;
- menuItem -l ("50% Globals (" + $x + "x" + $y + ")")
- -cb $halfBool
- -c "setTestResolutionVar(2)"
- ($panelName + "halfResolutionItem");
-
-
- $x = $res[0] / 4;
- $y = $res[1] / 4;
- menuItem -l ("25% Globals (" + $x + "x" + $y + ")")
- -cb $quaterBool
- -c "setTestResolutionVar(3)"
- ($panelName + "quaterResolutionItem");
-
- $x = $res[0] / 10;
- $y = $res[1] / 10;
- menuItem -l ("10% Globals (" + $x + "x" + $y + ")")
- -cb $tenthBool
- -c "setTestResolutionVar(4)"
- ($panelName + "tenthResolutionItem");
- }
-
- global proc renderWindowCreateCameraSubmenu(
- string $subMenu,
- string $command,
- string $editor)
- {
- popupMenu
- -edit
- -deleteAllItems
- $subMenu;
-
- setParent
- -menu
- $subMenu;
-
- //
- // Get the current model panel and then get the render view resolution.
- //
- string $camera = `getCurrentCamera`;
- string $cameraPanel = `getCameraPanel( $camera )`;
- int $resolution[] = `getTestResolution( $cameraPanel )`;
-
- //
- // Build items.
- //
-
- //
- // Create a menu item for the current camera
- //
- if( size($cameraPanel) != 0 )
- {
- menuItem
- -label ("Current ("+$camera+")")
- -command ($command + $camera);
- menuItem -divider true ;
- }
-
- //
- // Create a menu item for each of the perspective cameras
- //
- string $persps[] = `listCameras -perspective`;
-
- for( $camera in $persps )
- {
- menuItem
- -label $camera
- -command ($command + $camera);
- }
-
- menuItem -divider true;
-
- //
- // Create a menu item for each of the orthographic cameras
- //
- string $orthos[] = `listCameras -orthographic`;
-
- for( $camera in $orthos )
- {
- menuItem
- -label $camera
- -command ($command + $camera);
- }
- }
-
- //////////////////////////////////////////////////////////////////////
- //
- // Procedure Name:
- // buildRenderViewContextHelpItems
- //
- // Description:
- // Build context sensitive menu items for the render view.
- //
- // Input Arguments:
- // $nameRoot - name to use as the root of all item names
- // $menuParent - the name of the parent of this menu
- //
- // Return Value:
- // None
- //
- global proc buildRenderViewContextHelpItems(string $nameRoot, string $menuParent)
- {
- menuItem -label "Help on Render View..."
- -enableCommandRepeat false
- -command "showHelp RenderView";
- }
-
- global proc renderWindowRefreshMenu(string $menu, string $editor)
- {
-
- if(`about -mac`){
- string $panel = `getRenderWindowPanel`;
- string $renderPanels[] = `getPanel -vis`;
- int $count;
- for($count = 0; $count < size($renderPanels); $count++){
- if($renderPanels[$count] == $panel){
- break;
- }
- }
- if ($count == size($renderPanels)){
- return;
- }
- }
- if ($menu == "file")
- {
- refreshFileMenu($editor, "menubar");
- refreshFileMenu($editor, "popup");
- }
- else if ($menu == "render")
- {
- refreshRenderMenu($editor, "menubar");
- refreshRenderMenu($editor, "popup");
- }
- else if ($menu == "ipr")
- {
- refreshIprMenu($editor, "menubar");
- refreshIprMenu($editor, "popup");
- }
- else if ($menu == "options")
- {
- refreshOptionsMenu($editor, "menubar");
- refreshOptionsMenu($editor, "popup");
- }
- else if ($menu == "view")
- {
- refreshViewMenu($editor, "menubar");
- refreshViewMenu($editor, "popup");
- }
- else if ($menu == "display")
- {
- refreshDisplayMenu($editor, "menubar");
- refreshDisplayMenu($editor, "popup");
- }
- }
-
- //----------------------------------------------------------------------------//
- // Procedures which call the menu generation procedures and create other
- // user interface elements within the render view window or panel
- //----------------------------------------------------------------------------//
-
- proc createMenubar(string $editor)
- {
- createFileMenu($editor, "menubar");
- createViewMenu($editor, "menubar");
- createRenderMenu($editor, "menubar");
- createIprMenu($editor, "menubar");
- createOptionsMenu($editor, "menubar");
- createDisplayMenu($editor, "menubar");
- }
-
- proc createPopupMenu(string $editor)
- {
- popupMenu
- -button 3
- -parent $editor
- -allowOptionBoxes true
- ($editor + "popupMenu");
-
- createFileMenu($editor, "popup");
- createViewMenu($editor, "popup");
- createRenderMenu($editor, "popup");
- createIprMenu($editor, "popup");
- createOptionsMenu($editor, "popup");
- createDisplayMenu($editor, "popup");
- }
-
-
-
- proc createLayout(string $editor)
- {
- int $iconSize = 26;
-
- // Make sure that there is no template active
- setUITemplate -pushTemplate NONE;
-
- formLayout renderViewForm;
- formLayout toolbarForm;
- formLayout toolbar;
-
- string $currentRendererName = currentRenderer();
- string $renUIName = `renderer -query -rendererUIName $currentRendererName`;
-
- iconTextButton
- -i1 "rvRender.xpm"
- -width $iconSize -height $iconSize
- -annotation ("Redo Previous Render (" + $renUIName + ")")
- -command
- ("renderWindowRender redoPreviousRender " + $editor)
- renderButton;
-
- iconTextButton
- -i1 "rvIprRender.xpm"
- -width $iconSize -height $iconSize
- -annotation ("Redo Previous IPR Render (" + $renUIName + ")")
- -command
- ("renderWindowRender redoPreviousIprRender " + $editor)
- iprRenderButton;
-
- iconTextButton
- -i1 "rvRenderRegion.xpm"
- -width $iconSize -height $iconSize
- -annotation ("Render Region (" + $renUIName + ")")
- -command
- ("renderWindowRenderRegion " + $editor)
- renderRegionButton;
-
- iconTextButton
- -i1 "rvIPRRefresh.xpm"
- -width $iconSize -height $iconSize
- -annotation ("Refresh the IPR Image (" + $renUIName + ")")
- -command
- ("renderWindowMenuCommand refreshIprImage "
- + $editor)
- refreshIprButton;
-
- iconTextButton
- -i1 "rvAllPlanes.xpm"
- -width $iconSize -height $iconSize
- -annotation "Display RGB Channels"
- -command
- ("renderWindowEditor "
- + "-edit "
- + "-displayStyle \"color\" "
- + "-scaleRed 1 "
- + "-scaleGreen 1 "
- + "-scaleBlue 1 "
- + $editor )
- allPlanesButton;
-
- iconTextButton
- -i1 "rvMaskPlane.xpm"
- -width $iconSize -height $iconSize
- -annotation "Display Alpha Channel"
- -command
- ("renderWindowEditor "
- + "-edit "
- + "-displayStyle \"mask\" "
- + $editor )
- maskButton;
-
- iconTextButton
- -i1 "rvRealSize.xpm"
- -width $iconSize -height $iconSize
- -annotation "Display Real Size"
- -command
- ("renderWindowEditor "
- + "-edit "
- + "-realSize "
- + $editor)
- realSizeButton;
-
- iconTextButton
- -i1 "rvKeepIt.xpm"
- -width $iconSize -height $iconSize
- -annotation "Keep Image"
- -command
- ("renderWindowMenuCommand keepImageInRenderView " + $editor)
- keepImageButton;
-
- iconTextButton
- -i1 "rvRemoveIt.xpm"
- -width $iconSize -height $iconSize
- -annotation "Remove Image"
- -command
- ("renderWindowMenuCommand removeImageFromRenderView " + $editor)
- removeImageButton;
-
- iconTextButton
- -i1 "rvRenderGlobals.xpm"
- -width $iconSize -height $iconSize
- -annotation ("Open Render Globals Window (" + $renUIName+ ")")
- -command
- ("displayRenderGlobalsWindow")
- renderGlobalsButton;
-
- iconTextButton
- -i1 "rvDiagnostics.xpm"
- -width $iconSize -height $iconSize
- -annotation "Show Render Diagnostics in the Script Editor"
- -command "mayaRenderDiagnostics"
- diagnosticsButton;
-
- iconTextCheckBox
- -i1 "rvPauseIprTuning.xpm"
- -width $iconSize -height $iconSize
- -annotation "Pause IPR Tuning"
- -onCommand
- ("renderWindowMenuCommand togglePauseTuning " + $editor)
- -offCommand
- ("renderWindowMenuCommand togglePauseTuning " + $editor)
- pauseIprButton;
-
- text
- -label "IPR: 0MB"
- iprMemEstText;
-
- iconTextButton
- -i1 "rvIPRStop.xpm"
- -width $iconSize -height $iconSize
- -annotation "Close IPR File and Stop Tuning"
- -command
- ("renderWindowMenuCommand closeIprFile " + $editor)
- closeIprButton;
-
- // Renderer selection option menu
-
- string $renderers[] = `renderer -query -namesOfAvailableRenderers`;
- string $rendererUIName = "";
-
- optionMenu
- -annotation "Select Renderer"
- -cc "updateCurrentRendererSel(\"rendererSelOptionMenu\")"
- rendererSelOptionMenu;
-
- for ($i = 0; $i < size($renderers); $i += 1)
- {
- $rendererUIName = `renderer -query -rendererUIName $renderers[$i]`;
- menuItem -l $rendererUIName -enableCommandRepeat false ("rendererSelOptionMenuItem" +$i);
- }
-
- // Update the Renderer selection option box to reflect current renderer
- //
- for ($i = 0; $i < size($renderers); $i++)
- {
- if($renderers[$i] == currentRenderer())
- {
- optionMenu -edit -select ($i+1) rendererSelOptionMenu;
- }
- }
-
- separator -horizontal false -style single rvSeparator1;
- separator -horizontal false -style single rvSeparator2;
- separator -horizontal false -style single rvSeparator3;
- separator -horizontal false -style single rvSeparator4;
- separator -horizontal false -style single rvSeparator5;
- separator -horizontal false -style single rightSeparator;
-
- int $margin = 1;
-
- formLayout
- -edit
-
- -attachForm "renderButton" "left" $margin
- -attachNone "renderButton" "right"
- -attachForm "renderButton" "top" $margin
- -attachForm "renderButton" "bottom" $margin
-
- -attachControl "renderRegionButton" "left" $margin "renderButton"
- -attachNone "renderRegionButton" "right"
- -attachForm "renderRegionButton" "top" $margin
- -attachForm "renderRegionButton" "bottom" $margin
-
- -attachControl "rvSeparator1" "left" $margin "renderRegionButton"
- -attachNone "rvSeparator1" "right"
- -attachForm "rvSeparator1" "top" $margin
- -attachForm "rvSeparator1" "bottom" $margin
-
- -attachControl "iprRenderButton" "left" $margin "rvSeparator1"
- -attachNone "iprRenderButton" "right"
- -attachForm "iprRenderButton" "top" $margin
- -attachForm "iprRenderButton" "bottom" $margin
-
- -attachControl "refreshIprButton" "left" $margin "iprRenderButton"
- -attachNone "refreshIprButton" "right"
- -attachForm "refreshIprButton" "top" $margin
- -attachForm "refreshIprButton" "bottom" $margin
-
- -attachControl "rvSeparator2" "left" $margin "refreshIprButton"
- -attachNone "rvSeparator2" "right"
- -attachForm "rvSeparator2" "top" $margin
- -attachForm "rvSeparator2" "bottom" $margin
-
- -attachControl "renderGlobalsButton" "left" $margin "rvSeparator2"
- -attachNone "renderGlobalsButton" "right"
- -attachForm "renderGlobalsButton" "top" $margin
- -attachForm "renderGlobalsButton" "bottom" $margin
-
- -attachControl "rvSeparator3" "left" $margin "renderGlobalsButton"
- -attachNone "rvSeparator3" "right"
- -attachForm "rvSeparator3" "top" $margin
- -attachForm "rvSeparator3" "bottom" $margin
-
- -attachControl "allPlanesButton" "left" $margin "rvSeparator3"
- -attachNone "allPlanesButton" "right"
- -attachForm "allPlanesButton" "top" $margin
- -attachForm "allPlanesButton" "bottom" $margin
-
- -attachControl "maskButton" "left" $margin "allPlanesButton"
- -attachNone "maskButton" "right"
- -attachForm "maskButton" "top" $margin
- -attachForm "maskButton" "bottom" $margin
-
- -attachControl "realSizeButton" "left" $margin "maskButton"
- -attachNone "realSizeButton" "right"
- -attachForm "realSizeButton" "top" $margin
- -attachForm "realSizeButton" "bottom" $margin
-
- -attachControl "rvSeparator4" "left" $margin "realSizeButton"
- -attachNone "rvSeparator4" "right"
- -attachForm "rvSeparator4" "top" $margin
- -attachForm "rvSeparator4" "bottom" $margin
-
- -attachControl "keepImageButton" "left" $margin "rvSeparator4"
- -attachNone "keepImageButton" "right"
- -attachForm "keepImageButton" "top" $margin
- -attachForm "keepImageButton" "bottom" $margin
-
- -attachControl "removeImageButton" "left" $margin "keepImageButton"
- -attachNone "removeImageButton" "right"
- -attachForm "removeImageButton" "top" $margin
- -attachForm "removeImageButton" "bottom" $margin
-
- -attachControl "rvSeparator5" "left" $margin "removeImageButton"
- -attachNone "rvSeparator5" "right"
- -attachForm "rvSeparator5" "top" $margin
- -attachForm "rvSeparator5" "bottom" $margin
-
- -attachControl "diagnosticsButton" "left" $margin "rvSeparator5"
- -attachNone "diagnosticsButton" "right"
- -attachForm "diagnosticsButton" "top" $margin
- -attachForm "diagnosticsButton" "bottom" $margin
-
- -attachControl "rightSeparator" "left" $margin "diagnosticsButton"
- -attachNone "rightSeparator" "right"
- -attachForm "rightSeparator" "top" $margin
- -attachForm "rightSeparator" "bottom" $margin
-
- -attachControl "rendererSelOptionMenu" "left" $margin "rightSeparator"
- -attachNone "rendererSelOptionMenu" "right"
- -attachForm "rendererSelOptionMenu" "top" $margin
- -attachForm "rendererSelOptionMenu" "bottom" $margin
-
- -attachNone "closeIprButton" "left"
- -attachForm "closeIprButton" "right" $margin
- -attachForm "closeIprButton" "top" $margin
- -attachForm "closeIprButton" "bottom" $margin
-
- -attachNone "iprMemEstText" "left"
- -attachControl "iprMemEstText" "right" $margin "closeIprButton"
- -attachForm "iprMemEstText" "top" $margin
- -attachForm "iprMemEstText" "bottom" $margin
-
- -attachNone "pauseIprButton" "left"
- -attachControl "pauseIprButton" "right" $margin "iprMemEstText"
- -attachForm "pauseIprButton" "top" $margin
- -attachForm "pauseIprButton" "bottom" $margin
-
- toolbar;
-
- setParent ..;
- formLayout
- -edit
- -attachForm "toolbar" "left" 0
- -attachForm "toolbar" "right" 0
- -attachForm "toolbar" "top" 0
- -attachForm "toolbar" "bottom" 0
- toolbarForm;
- setParent ..;
-
- formLayout editorForm;
- renderWindowEditor
- -edit
- -parent "editorForm"
- $editor;
- formLayout
- -edit
- -attachForm $editor "left" 0
- -attachForm $editor "right" 0
- -attachForm $editor "top" 0
- -attachForm $editor "bottom" 0
- editorForm;
- setParent ..;
-
- formLayout scrollBarForm;
- intScrollBar
- -step 1
- -largeStep 1
- -height 15
- -horizontal true
- -changeCommand
- ("renderWindowScrollDisplayImage "
- + $editor)
- scrollBar;
- formLayout
- -edit
- -attachForm "scrollBar" "left" 0
- -attachForm "scrollBar" "right" 0
- -attachForm "scrollBar" "top" 0
- -attachForm "scrollBar" "bottom" 0
- scrollBarForm;
- setParent ..;
-
- // Needed on Mac :
- // Add an offset for right attachment of the scrollBar.
- // This prevents resize handle of window from overlapping
- // onto the scrollbar's up/down arrows
- //
- int $scrollBarRightSpacing, $editorFormBottomSpacing;
- if (`about -mac`) {
- $scrollBarRightSpacing = 12;
- $editorFormBottomSpacing = 10;
- } else {
- $scrollBarRightSpacing = 0;
- $editorFormBottomSpacing = 0;
- }
-
- formLayout
- -edit
-
- -attachForm "toolbarForm" "left" 0
- -attachForm "toolbarForm" "right" 0
- -attachForm "toolbarForm" "top" 0
- -attachNone "toolbarForm" "bottom"
-
- -attachForm "editorForm" "left" 0
- -attachForm "editorForm" "right" 0
- -attachControl "editorForm" "top" 0 "toolbarForm"
- -attachControl "editorForm" "bottom" $editorFormBottomSpacing "scrollBarForm"
-
- -attachForm "scrollBarForm" "left" 0
- -attachForm "scrollBarForm" "right" $scrollBarRightSpacing
- -attachNone "scrollBarForm" "top"
- -attachForm "scrollBarForm" "bottom" 0
-
- renderViewForm;
-
- createPopupMenu($editor);
-
- setUITemplate -popTemplate;
- }
-
- // Description: This procedure is called to refresh the renderer specific
- // in the render view window.
- //
- proc renderWindowRendererSpecificRefresh(string $parent)
- {
- setParent $parent;
-
- string $currentRendererName = currentRenderer();
- string $renUIName = `renderer -query -rendererUIName $currentRendererName`;
-
- // Refresh captions of render buttons to update current renderer tag
- //
- iconTextButton -edit
- -annotation ("Redo Previous Render (" + $renUIName+ ")")
- renderButton;
-
- iconTextButton -edit
- -annotation ("Render Region (" + $renUIName+ ")")
- renderRegionButton;
-
- iconTextButton -edit
- -annotation ("Open Render Globals Window (" + $renUIName+ ")")
- renderGlobalsButton;
-
- global int $gIprTuningPaused;
-
- if (`renderer -query -iprRenderProcedure $currentRendererName` != "")
- {
- // enable IPR related UI if current renderer supports IPR
- //
- iconTextButton -edit
- -enable true
- -annotation ("Redo Previous IPR Render (" + $renUIName+ ")")
- iprRenderButton;
-
- if (isIprFileLoaded()) {
- text -edit -enable true iprMemEstText;
- iconTextButton -edit
- -enable true
- -annotation ("Close IPR File and Stop Tuning")
- closeIprButton;
-
- iconTextCheckBox -edit
- -enable true
- -annotation ("Pause IPR Tuning")
- pauseIprButton;
-
- iconTextButton -edit
- -enable (!$gIprTuningPaused)
- -annotation ("Refresh the IPR Image (" + $renUIName+ ")")
- refreshIprButton;
- } else {
- text -edit -enable false iprMemEstText;
- iconTextButton -edit
- -enable false
- -annotation ("")
- closeIprButton;
-
- iconTextCheckBox -edit
- -enable false
- -annotation ("")
- pauseIprButton;
-
- iconTextButton -edit
- -enable false
- -annotation ("")
- refreshIprButton;
- }
-
- // Adjust the "Pause IPR Tuning" icon to be pressed if tuning is paused,
- // or not pressed if tuning is not paused.
- //
- if ($gIprTuningPaused)
- {
- iconTextCheckBox -edit -value true pauseIprButton;
- }
- else
- {
- iconTextCheckBox -edit -value false pauseIprButton;
- }
-
- }
- else
- {
- // If the current renderer does not support IPR, disable all
- // ipr related UI
- //
- text -edit -enable false iprMemEstText;
-
- iconTextButton -edit
- -enable false
- -annotation ("Not available for this renderer")
- closeIprButton;
-
- iconTextCheckBox -edit
- -enable false
- -annotation ("Not available for this renderer")
- pauseIprButton;
-
- iconTextButton -edit
- -enable false
- -annotation ("Not available for this renderer")
- refreshIprButton;
-
- iconTextCheckBox -edit -value false pauseIprButton;
-
- iconTextButton -edit
- -enable false
- -annotation ("Not available for this renderer")
- iprRenderButton;
- }
-
- // Disable render diagnostics button if the feature is not
- // supported by the current renderer
- //
- if (`renderer -query -renderDiagnosticsProcedure $currentRendererName` != "")
- {
- iconTextButton -edit
- -enable true
- -annotation ("Show Render Diagnostics in the Script Editor")
- diagnosticsButton;
- }
- else
- {
- iconTextButton -edit
- -enable false
- -annotation ("")
- diagnosticsButton;
- }
-
-
- string $renderers[] = `renderer -query -namesOfAvailableRenderers`;
-
- // Check for any updates in the renderer list
- //
- int $numItems = `optionMenu -query -numberOfItems rendererSelOptionMenu`;
-
- // Make sure all the renderers are being shown in the option menu
- //
- if($numItems != size($renderers))
- {
-
- setParent -menu rendererSelOptionMenu;
-
- string $menuItemNames[] = `optionMenu -query -itemListLong rendererSelOptionMenu`;
-
- // Remove all the menuItems and create new ones to reflect the
- // renderers currently available
- //
- for ($i = 0; $i < size($menuItemNames); $i++)
- {
- deleteUI $menuItemNames[$i];
- }
-
- for ($i = 0; $i < size($renderers); $i++)
- {
- $rendererUIName = `renderer -query -rendererUIName $renderers[$i]`;
- menuItem -l $rendererUIName -enableCommandRepeat false ("rendererSelOptionMenuItem" +$i);
- }
-
- setParent ..;
-
- }
-
- // Update the Renderer selection option box to reflect current renderer
- //
-
- for ($i = 0; $i < size($renderers); $i++)
- {
- if($renderers[$i] == currentRenderer())
- {
- optionMenu -edit -select ($i+1) rendererSelOptionMenu;
- }
- }
- }
-
- global proc renderWindowRefreshLayout(string $editor)
- {
-
- if(`about -mac`){
- string $panel = `getRenderWindowPanel`;
- string $renderPanels[] = `getPanel -vis`;
- int $count;
- for($count = 0; $count < size($renderPanels); $count++){
- if($renderPanels[$count] == $panel){
- break;
- }
- }
- if ($count == size($renderPanels)){
- return;
- }
- }
- setParent $editor;
- formLayout -edit -manage false renderViewForm;
-
- if (isToolbarDisplayed())
- {
- formLayout
- -edit
- -manage true
- toolbar;
- }
- else
- {
- formLayout
- -edit
- -manage false
- toolbar;
- }
-
- //
- // Refresh the scroll bar
- //
-
- // Determine how many images are stored in the buffer
- //
- int $numImages =
- `renderWindowEditor
- -query
- -nbImages
- $editor`;
-
- // Determine what the index of the current image is
- //
- int $currImage =
- `renderWindowEditor
- -query
- -displayImage
- $editor`;
-
- if ($numImages > 0)
- {
- // There is at least one image in the buffer, so we should display the
- // scroll bar with appropriate max, min and index.
- //
- intScrollBar
- -edit
- -manage true
- -min -1
- -max ($numImages - 1)
- -value $currImage
- scrollBar;
-
- // Fix for Bug #147008
- // Adjust the editor form bottom,
- // so that it does not overlap onto window resize handle
- //
- if(`about -mac`)
- {
- int $scrollBarRightSpacing = 12 ;
-
- formLayout
- -edit
-
- -attachForm "toolbarForm" "left" 0
- -attachForm "toolbarForm" "right" 0
- -attachForm "toolbarForm" "top" 0
- -attachNone "toolbarForm" "bottom"
-
- -attachForm "editorForm" "left" 0
- -attachForm "editorForm" "right" 0
- -attachControl "editorForm" "top" 0 "toolbarForm"
- -attachControl "editorForm" "bottom" 0 "scrollBarForm"
-
- -attachForm "scrollBarForm" "left" 0
- -attachForm "scrollBarForm" "right" $scrollBarRightSpacing
- -attachNone "scrollBarForm" "top"
- -attachForm "scrollBarForm" "bottom" 0
-
- renderViewForm;
- }
- }
- else
- {
- // There aren't any images in the buffer.
- // Hide the scroll bar.
- //
- intScrollBar
- -edit
- -manage false
- scrollBar;
-
- // Fix for Bug #147008
- // Adjust the editor form bottom,
- // so that it does not overlap onto window resize handle
- //
- if(`about -mac`)
- {
- int $scrollBarRightSpacing = 12 ;
- int $editorFormBottomSpacing = 10 ;
-
- formLayout
- -edit
-
- -attachForm "toolbarForm" "left" 0
- -attachForm "toolbarForm" "right" 0
- -attachForm "toolbarForm" "top" 0
- -attachNone "toolbarForm" "bottom"
-
- -attachForm "editorForm" "left" 0
- -attachForm "editorForm" "right" 0
- -attachControl "editorForm" "top" 0 "toolbarForm"
- -attachControl "editorForm" "bottom" $editorFormBottomSpacing "scrollBarForm"
-
- -attachForm "scrollBarForm" "left" 0
- -attachForm "scrollBarForm" "right" $scrollBarRightSpacing
- -attachNone "scrollBarForm" "top"
- -attachForm "scrollBarForm" "bottom" 0
-
- renderViewForm;
- }
- }
-
- // Refresh the renderer specific UIs in render window layout.
- //
- string $currentParent = `setParent -q`;
- renderWindowRendererSpecificRefresh($currentParent);
-
- formLayout -edit -manage true renderViewForm;
- }
-
- //----------------------------------------------------------------------------//
- // Procedures which are accessed from outside the renderview
- //----------------------------------------------------------------------------//
-
- global proc renderIntoNewWindow(string $renderMode)
- {
- // Determine what model panel the user wants to render.
- //
- string $currentPanel = `getPanel -wf`;
- string $camera = "";
-
- if( `getPanel -to $currentPanel` != "modelPanel" )
- {
- if (`getPanel -to $currentPanel` == "scriptedPanel") {
- // It is potentially a Paint Effects panel.
- if ( `scriptedPanel -q -l $currentPanel` == "Paint Effects" ) {
- // It is! It is a Paint Effects panel. Get the name of the camera we are using.
- if (`about -mac`) {
- // Temporary fix for 4.5. getPanel needs to be properly fixed in 5.0 for Mac.
- string $dynPanel = `getPanel -containing dynPaintScriptedPanelEd`;
- if ((size($dynPanel) != 0)) {
- $camera = `dynPaintEditor -query -camera dynPaintScriptedPanelEd`;
- }
- } else {
- $camera = `dynPaintEditor -query -camera dynPaintScriptedPanelEd`;
- }
- }
- }
- if ($camera == "") {
- confirmDialog
- -message "Please select the view you want to render"
- -button "OK"
- -defaultButton "OK";
- return;
- }
- }
- else
- {
- // Find out what the current camera is
- //
- $camera = `modelPanel -query -camera $currentPanel`;
- }
-
- // Get the render view.
- //
- string $editor = `getRenderWindowPanel`;
-
- //
- // If not tore off, do It !
- //
- if( !`scriptedPanel -q -tearOff $editor` )
- {
- scriptedPanel -e -tearOff $editor;
- }
-
- //
- // Now gets the right resolution.
- //
- int $res[] = `getTestResolution( $currentPanel )`;
-
- //
- // If the render view is too small, resize it.
- //
- string $renderWindowControl = `scriptedPanel -q -control $editor`;
- string $renderWindow;
- string $buffer[];
-
- tokenize( $renderWindowControl, "|", $buffer );
- $renderWindow = $buffer[0];
-
- int $width = `control -q -w $renderWindowControl`;
- int $height = `control -q -h $renderWindowControl`;
-
- $width -= 40;
- $height -= 60;
-
- if( $width < $res[0] || $height < $res[1] )
- {
- $width = $res[0] + 40;
- $height = $res[1] + 60;
- window -e -w $width -h $height -retain $renderWindow;
- }
-
- //
- // Render the current camera panel at the test resolution...
- //
- showWindow $renderWindow;
-
- renderWindowRenderCamera($renderMode, $editor, $camera);
- }
-
-
- // This one can be used by hotkeys to check whether the render view is
- // visible or not before calling redoLastRender procedure.
- //
- global proc redoPreviousRender(string $renderMode)
- {
- string $editor = `showRenderView`;
- renderWindowRender($renderMode, $editor);
- }
-
- global proc renderWindowScrollDisplayImage(string $editor)
- {
- int $index =
- `intScrollBar
- -query
- -value
- scrollBar`;
-
- renderWindowEditor
- -edit
- -displayImage $index
- $editor;
-
- renderWindowRefreshMenu("file", $editor);
- }
-
- //----------------------------------------------------------------------------//
- // Procedures which support scripted panel capability
- //----------------------------------------------------------------------------//
-
- global proc createRenderWindowPanel(string $whichPanel)
- {
- renderWindowEditor -unParent $whichPanel ;
-
- //
- // Set the options variables.
- //
- setRenderOptionVars;
-
- // Adds support for the Context Sensitive Help Menu.
- //
- addContextHelpProc $whichPanel "buildRenderViewContextHelpItems";
- }
-
- global proc addRenderWindowPanel(string $editor)
- {
- //
- // Build Menubar.
- //
- createMenubar($editor);
-
- // Create the layout of the renderview
- //
- createLayout($editor);
- renderWindowRefreshLayout($editor);
-
- //
- // Tells the renderWindowEditor what the renderViewAutoResize value
- // is.
- //
- $var = `optionVar -q renderViewAutoResize`;
- renderWindowEditor -e -ar $var $editor;
- }
-
- global proc removeRenderWindowPanel(string $whichPanel)
- {
- renderWindowEditor -e -unParent $whichPanel ;
- }
-
-
- global proc renderWindowPanel(string $panelName)
- //
- // Description:
- // This proc defines the render window panel type and instantiates
- // one.
- //
- {
- global string $gMainPane;
-
- // Define the type of panel and its callbacks
- //
- if (!`scriptedPanelType -exists renderWindowPanel`)
- {
- scriptedPanelType
- -unique true
- -createCallback "createRenderWindowPanel"
- -addCallback "addRenderWindowPanel"
- -removeCallback "removeRenderWindowPanel"
- renderWindowPanel;
-
- // Create an instance of the render window panel
- //
- setParent $gMainPane;
- scriptedPanel -unParent -type "renderWindowPanel" $panelName;
- }
- }
-
- //
- // Description:
- // This procedure is called by TrenderWindowSelectCtx.cc that defines
- // a region. It checks if a region can be rendered.
- //
- global proc renderWindowCheckAndRenderRegion
- ( float $top,
- float $left,
- float $bottom,
- float $right )
- {
- //
- // If there's no current camera (first render), do what has to be
- // done...
- //
- string $renderPanel = `getRenderWindowPanel`;
- int $snapped = 0;
-
- if (!isIprFileLoaded()) {
- if( `renderWindowEditor -q -currentCamera $renderPanel` == "" )
- {
- //
- // Take a snapshot of the first persp camera found.
- //
- string $cameras[] = `listCameras -perspective`;
-
- if( size($cameras) )
- {
- string $camera = $cameras[0];
- string $panel = `getCameraPanel( $camera )`;
- int $res[] = `getTestResolution( $panel )`;
-
- renderWindowTakeSnapshot( $res[0], $res[1], $camera );
- $snapped = 1;
- }
- else
- {
- $cameras = `listCameras`;
-
- if( size($cameras) )
- {
- string $camera = $cameras[0];
- string $panel = `getCameraPanel( $camera )`;
- int $res[] = `getTestResolution( $panel )`;
-
- renderWindowTakeSnapshot( $res[0], $res[1], $camera );
- $snapped = 1;
- }
- }
- }
- else
- $snapped = 1;
- } else
- $snapped = 1;
-
-
- //
- // Otherwise, set the region and render if the renderViewAutoRenderRegion
- // is set to true.
- //
- if( $snapped )
- {
- renderWindowEditor -e -mq $top $left $bottom $right $renderPanel;
-
- // We can't autoRenderRegion if ipr is on
- if( `optionVar -exists renderViewAutoRenderRegion` &&
- `optionVar -query renderViewAutoRenderRegion` != 0 &&
- !isIprFileLoaded())
- {
- string $editor = `showRenderView`;
- renderWindowRenderRegion($editor);
- }
-
- }
-
- if (isIprFileLoaded())
- {
- global int $gIprTuningPaused;
-
- if ($gIprTuningPaused)
- {
- renderWindowMenuCommand("togglePauseTuning", $renderPanel);
- }
-
- // Tell the IPR engine what the current marquee is
- //
- int $top;
- int $left;
- int $bottom;
- int $right;
-
- string $renderGlobals[] = `ls -renderGlobals`;
-
- $bottom = `getAttr ($renderGlobals[0] + ".bottomRegion")`;
- $left = `getAttr ($renderGlobals[0] + ".leftRegion")`;
- $top = `getAttr ($renderGlobals[0] + ".topRegion")`;
- $right = `getAttr ($renderGlobals[0] + ".rightRegion")`;
-
- iprEngine
- -edit
- -region $left $bottom $right $top
- defaultIprEngine;
-
- loadSamples($renderPanel);
- }
- }
-
- //
- // Description:
- // This procedure is called when an image is to be rendered using
- // the maya renderer. It is used to standardize the render command
- // calls , since not all renderers take the same arguments
- // Returns: render result
- //
- global proc string mayaSoftwareRender(int $width, int $height, int $doShadows,
- int $doGlowPass, string $camera)
- {
- string $result;
- $result = `render -x $width -y $height -nsh $doShadows
- -ngl $doGlowPass $camera`;
- return $result;
- }
-
- //
- // Description:
- // Checks if the current render supports the reder region feature
- // and if so, calls the render region procedure for the current renderer.
- // Returns: None
- //
- global proc renderWindowRenderRegion(string $editor)
- {
- string $command;
-
-
- string $renderer;
-
- $renderer = currentRenderer();
- string $renUIName = `renderer -query -rendererUIName $renderer`;
-
- // if render region is support calls the corresponding
- // procedure for the current renderer
- //
- $command = `renderer -query -renderRegionProcedure $renderer`;
- if ($command != "")
- {
- catch($result = `eval $command $editor`);
-
- renderWindowEditor
- -edit
- -pca ($renUIName)
- $editor;
- }
- else
- {
- // Feature not supported: report error
- //
- warning
- ("Current Renderer "
- + $renUIName
- + " does not support render region");
- }
- }
-
- //
- // Description:
- // This procedure is called when a render region command is issued
- // for the maya software renderer. It is used to standardize the render
- // command calls , since not all renderers take the same arguments
- // Returns: render result
- //
- global proc mayaRenderRegion(string $editor)
- {
- string $cmd = "renderWindowRender renderRegion";
- eval $cmd $editor;
- }
-
-
- //
- // Description: Builds the "Render Using" Menu to allow for renderer selection
- // Returns: None
- //
- global proc buildRenderUsingMenu
- ( string $subMenuName,
- string $panelName )
- {
- popupMenu -e -deleteAllItems $subMenuName;
- setParent -m $subMenuName;
-
- string $renderers[] = `renderer -query -namesOfAvailableRenderers`;
- int $isCurrent = 0;
- string $funcName = "";
- string $rendererUIName = "";
-
-
- radioMenuItemCollection ("renderWindowRenderUsingCollection" + $subMenuName);
-
- for ($i = 0; $i < size($renderers); $i += 1)
- {
- if($renderers[$i] == currentRenderer())
- {
- $isCurrent = 1;
- }
- else
- {
- $isCurrent = 0;
- }
-
- $funcName = "setCurrentRenderer " + $renderers[$i];
- $rendererUIName = `renderer -query -rendererUIName $renderers[$i]`;
-
-
- menuItem -l $rendererUIName
- -radioButton $isCurrent
- -collection ("renderWindowRenderUsingCollection" + $subMenuName)
- -c $funcName
- ($panelName + "renderUsingItem" + $i);
- }
- }
-
- //
- // Description: Called when UI specific to the current renderer has to be
- // updated (usually when current renderer is changed).
- //
- // Returns: None.
- //
- global proc updateRenderWindowPanelRendererSpecificUI()
- {
-
- string $panel = `getRenderWindowPanel`;
- string $renderWindowControl = `scriptedPanel -q -control $panel`;
- string $renderWindow;
- string $buffer[];
- tokenize( $renderWindowControl, "|", $buffer );
- $renderWindow = $buffer[0];
-
- string $renderWindowExists = `window -ex $renderWindow`;
-
- if($renderWindowExists)
- {
- // Make sure the option menu exists.
- // The only time the render window panel is open and the
- // option menu does not exist is when the render window panel
- // is open on plug-in load
- //
- if(!`optionMenu -query -exists rendererSelOptionMenu`)
- {
- string $parent;
-
- // Get the name of the parent (i.e one level above
- // $renderWindowControl). In order to do this we break up the name
- // and re-assemble it leaving out the last control.
- //
- $parent = $buffer[0];
-
- for($i = 1; $i < size($buffer) - 1; $i++)
- {
- $parent = $parent + "|" + $buffer[$i];
- }
-
- // In order to update all the menu toolbar, the panel is removed and
- // inserted back
- //
- scriptedPanel -edit -unParent $panel;
- scriptedPanel -edit -parent $parent $panel;
-
- }
-
- renderWindowRefreshMenu("ipr",$panel);
- renderWindowRendererSpecificRefresh($panel);
- }
- }
-
- // Register the procedure responsible for updating all renderer
- // related UI created in this script.
- //
- registerUpdateRendererUIProc("updateRenderWindowPanelRendererSpecificUI");
-
-